home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Programmation / Alpha ƒ / Tcl / SystemCode / latexMacros.tcl (.txt) < prev    next >
LaTeX Document  |  1996-01-21  |  93KB  |  2,666 lines

  1. #############################################################################
  2. #############################################################################
  3. # latexMacros.tcl (called from latex.tcl)
  4. #############################################################################
  5. # Author:  Tom Scavo <trscavo@syr.edu>
  6. #############################################################################
  7. #############################################################################
  8. #############################################################################
  9. # Basic Commands
  10. #############################################################################
  11. proc typeset {} {
  12.     global PREFS
  13.     set currentWin [lindex [winNames -f] 0]
  14.     set currentDir [file dirname $currentWin]
  15.     set currentDoc [file tail $currentWin]
  16.     set docBasename [file rootname $currentDoc]
  17.     set docExtension [file extension $currentDoc]
  18.     # Is the window untitled or dirty?
  19.     if {[string match $currentWin $currentDoc]} {
  20.         case [askyesno -c "Save \"$currentDoc\"?"] in {
  21.             "yes" {
  22.                 if {[catch {set currentWin [saveAs "Untitled\.tex"]}]} then {return}
  23.             "no" {
  24.                 if {[regexp {<(.*)>} $currentDoc dummy num]} {
  25.                     set tmpFilename "Untitled$num\.tex"
  26.                 } else {
  27.                     set tmpFilename "Untitled\.tex"
  28.                 }
  29.                 set text [getText 0 [maxPos]]
  30.                 set newDoc "$PREFS:$tmpFilename"
  31.                 message "Saving $newDoc..."
  32.                 set fd [open $newDoc "w"]
  33.                 puts $fd $text
  34.                 close $fd
  35.                 set currentWin $newDoc
  36.             "cancel" {return}
  37.     } elseif {[winDirty]} {
  38.         case [askyesno -c "Save \"$currentDoc\"?"] in {
  39.             "yes" {save}
  40.             "no" {
  41.                 set text [getText 0 [maxPos]]
  42.                 set newDoc "$PREFS:temp-$currentDoc"
  43.                 message "Saving $newDoc..."
  44.                 set fd [open $newDoc "w"]
  45.                 puts $fd $text
  46.                 close $fd
  47.                 set currentWin $newDoc
  48.             "cancel" {return}
  49.     typesetFile $currentWin
  50. proc typesetSelection {} {
  51.     global PREFS
  52.     if { [isSelection] } then { 
  53.         set pos1 [getPos]
  54.         if { [isInDocument] } then {
  55.             exchangePointAndMark
  56.             set pos2 [getPos]
  57.             if { [isInDocument] } then {
  58.                 # fall through
  59.             } else {
  60.                 beep
  61.                 set msg "Selection not in document environment.  Continue?"
  62.                 if { [askyesno $msg] == "no" } then { return }
  63.         } else {
  64.             beep
  65.             set msg "Selection not in document environment.  Continue?"
  66.             if { [askyesno $msg] == "no" } then { return }
  67.             set pos2 [selEnd]
  68.         set body "\r[getText $pos1 $pos2]\r"
  69.         set pattern {(\\documentclass.*)\\begin\{document\}}
  70.         set searchText [getText 0 [maxPos]]
  71.         if {![regexp $pattern $searchText dummy preamble]} then {
  72.             set preamble "\\documentclass\{article\}\r"
  73.         append text $preamble [buildEnvironment "document" "" $body "\r"]
  74.         select $pos1 $pos2
  75.         set newDoc "$PREFS:temp-noname\.tex"
  76.         message "Saving $newDoc..."
  77.         set fd [open $newDoc "w"]
  78.         puts $fd $text
  79.         close $fd
  80.         set currentWin $newDoc
  81.         typesetFile $currentWin
  82.     } else {
  83.         beep
  84.         message "no selection"
  85. proc typesetFile {filename} {
  86.     global texPath TeXmodeVars
  87.     # Initialization:
  88.     foreach flag {isOzTeX isTextures isCMacTeX isDirectTeX isDirectTeXPro} {
  89.         set $flag 0
  90.     # Check if a TeX app is running.  If not, open the app named in 
  91.     # $texPath (if defined) or have the user select an app via a
  92.     # standard file dialog.  Leave the TeX app in the background.
  93.     set appName [checkRunning TeX {OTEX *TEX *XeT MPS* TeX+} texPath 0]
  94.     if {[string match {*OzTeX*} $appName]} {
  95.         set isOzTeX 1
  96.     } elseif {[string match {*Textures*} $appName]} {
  97.         set isTextures 1
  98.     } elseif {[string match {DirectTeX*} $appName]} {
  99.         set isDirectTeXPro 1
  100.     } elseif {[string match {*tex} $appName]} {
  101.         set isCMacTeX 1
  102.     } elseif {[string match {MPW*} $appName]} {
  103.         set isDirectTeX 1
  104.     } else {
  105.         alertnote "Sorry, I don't know how to talk to \"$appName\"."
  106.         return
  107.     # Conditionally bring the TeX app to the foreground:
  108.     if {$TeXmodeVars(runTeXInBackground) == 0} { switchTo $appName }
  109.     # Typeset the document:
  110.     if {$isOzTeX} {
  111.         sendOpenEvent -n $appName $filename
  112.     } elseif {$isTextures} {
  113.         # Choose one of the following three options:
  114.         # dosc -c '*TEX' -s [getText 0 [maxPos]] -r
  115.         # sendOpenEvent -n $appName $filename
  116.         dosc -c '*TEX' -f [lindex [winNames -f] 0] -r
  117.     } elseif {$isDirectTeXPro} {
  118. #         dosc -c 'TeX+' -s "ProjectMgr -t LaTeX \"$filename\"; SelectApp; MenuCommand 1 4"
  119. #         dosc -c 'TeX+' -s "ProjectMgr -t \$dt_DefaultFormat \"$filename\"; MenuCommand 1 4;"
  120.         dosc -c 'TeX+' -s "if \$dt_TeXFormat = \'\' \"set dt_TeXFormat -x \$dt_DefaultFormat\""
  121.         dosc -c 'TeX+' -s "ProjectMgr -t \$dt_TeXFormat \"$filename\"; MenuCommand 1 4"
  122.     } elseif {$isCMacTeX} {
  123.         dosc -n $appName -k 'aevt' -e 'odoc' -r -f $filename
  124.     } elseif {$isDirectTeX} {
  125.         set script "Begin; ChangeTeXProject '$filename' -check -confirm || Exit 0;\
  126.                       Execute \"{dt_TeXProject}\"; TeXMenu -tex -formats; End 
  127.  Dev:Null;\
  128.                       RunSession 1 
  129.  Dev:Null"
  130.         dosc -r -n $appName -s $script
  131. #--------------------------------------------------------------------------
  132. # Goto:
  133. #--------------------------------------------------------------------------
  134. # Switch to (but don't execute) any of the following applications.
  135. proc latex {} {
  136.     global texPath
  137.     if {![catch {getFileSig $texPath} sig]} {
  138.         set appName [checkRunning TeX $sig texPath]
  139.     } else {
  140.         set appName [checkRunning TeX {OTEX *TEX *XeT MPS* TeX+} texPath]
  141.     if {[string length $appName] > 0} {
  142.         switchTo $appName
  143. proc bibtex {} {
  144.     global bibtexPath
  145.     set appName [checkRunning BibTeX BIBt bibtexPath]
  146.     if {![string length $appName]} return
  147.     switchTo $appName
  148. proc makeindex {} {
  149.     global makeindexPath
  150.     set appName [checkRunning MakeIndex Midx makeindexPath]
  151.     if {![string length $appName]} return
  152.     switchTo $appName
  153. # Find the next or previous environment.  Search forward (or backward, 
  154. # depending on $forward) for either \begin or \end.  If \begin is found, 
  155. # search forward for corresponding \end; otherwise, search backward for 
  156. # corresponding \begin.  Select the found environment, or display an 
  157. # error message if no environment is found.
  158. proc findEnvironment {forward} {
  159.     set searchString1 {^[ \t]*\\begin\{[^\{\}]*\}|\\end\{[^\{\}]*\}[ \t]*\r?}
  160.     set searchPos [getPos]
  161.     if { [isSelection] } then { 
  162.         if { $forward } then {
  163.             set searchPos [selEnd]
  164.         } else {
  165.             set searchPos [expr $searchPos - 1]
  166.     } else {
  167.         if { $forward } then {
  168.             set searchPos [expr $searchPos + 1]
  169.         } else {
  170.             set searchPos [expr $searchPos - 1]
  171.     set searchResult [search -s -f $forward -r 1 -n $searchString1 $searchPos]
  172.     if {[string length $searchResult]} then {
  173.         set begPos [lindex $searchResult 0]
  174.         set endPos [lindex $searchResult 1]
  175.         set searchText [getText $begPos $endPos]
  176.         regexp {\{(.*)\}} $searchText dummy envName
  177.         if {[string match {*begin*} $searchText]} {
  178.             set begEnv $begPos
  179.             append searchString2 {\\end\{} $envName {\}[ \t]*\r?}
  180.             set searchPos $endPos
  181.             set searchResult [search -s -f 1 -r 1 -n $searchString2 $searchPos]
  182.             if {[string length $searchResult]} {
  183.                 set endPos [lindex $searchResult 1]
  184.                 return [list $begPos $endPos]
  185.             } else {
  186.                 return "matching \\end not found"
  187.         } else {
  188.             set endEnv $endPos
  189.             append searchString2 {^[ \t]*\\begin\{} $envName {\}}
  190.             set searchPos $begPos
  191.             set searchResult [search -s -f 0 -r 1 -n $searchString2 $searchPos]
  192.             if {[string length $searchResult]} {
  193.                 set begPos [lindex $searchResult 0]
  194.                 return [list $begPos $endPos]
  195.             } else {
  196.                 return "matching \\begin not found"
  197.     } else {
  198.         if { $forward } then {
  199.             return "next environment not found"
  200.         } else {
  201.             return "previous environment not found"
  202. proc prevEnvironment {} {
  203.     global searchNoisily
  204.     set findResult [findEnvironment 0]
  205.     if {[llength $findResult] == 2} then {
  206.         goto [lindex $findResult 0]
  207.     } else {
  208.         if {$searchNoisily} {beep}
  209.         message $findResult
  210. proc nextEnvironment {} {
  211.     global searchNoisily
  212.     set findResult [findEnvironment 1]
  213.     if {[llength $findResult] == 2} then {
  214.         goto [lindex $findResult 0]
  215.     } else {
  216.         if {$searchNoisily} {beep}
  217.         message $findResult
  218. proc prevEnvironmentSelect {} {
  219.     global searchNoisily
  220.     set forward 0
  221.     set findResult [findEnvironment $forward]
  222.     if {[llength $findResult] == 2} then {
  223.         set endPos [lindex $findResult 1]
  224. #         if { [regexp {\r} [lookAt [expr $endPos + 1]]] } then {
  225. #             set endPos [expr $endPos + 1]
  226. #         }
  227.         select [lindex $findResult 0] $endPos
  228.     } else {
  229.         if { $searchNoisily } {beep}
  230.         message $findResult
  231. proc nextEnvironmentSelect {} {
  232.     global searchNoisily
  233.     set forward 1
  234.     set findResult [findEnvironment $forward]
  235.     if {[llength $findResult] == 2} then {
  236.         set endPos [lindex $findResult 1]
  237. #         if { [regexp {\r} [lookAt [expr $endPos + 1]]] } then {
  238. #             set endPos [expr $endPos + 1]
  239. #         }
  240.         select [lindex $findResult 0] $endPos
  241.     } else {
  242.         if { $searchNoisily } {beep}
  243.         message $findResult
  244. # Find a LaTeX command in either direction.  It's up to the calling
  245. # procedure to pass the correct starting position of the search.
  246. proc findCommand {pos direction} {
  247. #    Handle "\ " and "\[" separately:
  248.     set searchString {(\\([^a-zA-Z\t\r* []|[a-zA-Z]+)\*?)|([^\\]\\\ )|([^\\]\\\[)}
  249.     set searchResult [search -s -f $direction -r 1 -n $searchString $pos]
  250.     if { [string length $searchResult] } {
  251.         set begPos [lindex $searchResult 0]
  252.         set endPos [lindex $searchResult 1]
  253.         set lastChar [lookAt [expr $endPos - 1]]
  254.         if {$lastChar == "\ " || $lastChar == "\["} then {
  255.             return [list [expr $begPos + 1] $endPos]
  256.         } else {}
  257.     return $searchResult
  258. # Handles everything but "\ " and "\[":
  259. #     set searchString {\\([^a-zA-Z\t\r* []|[a-zA-Z]+)\*?}
  260. #     return [search -s -f $direction -r 1 -n $searchString $pos]
  261. # Find and goto the beginning of the previous LaTeX command.
  262. proc prevCommand {} {
  263.     global searchNoisily
  264.     set pos [getPos]
  265.     if {$pos > 0} then {
  266.         set searchResult [findCommand [expr $pos - 1] 0]
  267.         if { [string length $searchResult] } {
  268.             goto [lindex $searchResult 0]
  269.             return
  270.         } else {}
  271.     if { $searchNoisily } {beep}
  272.     message "previous command not found"
  273. # Find and goto the beginning of the next LaTeX command.
  274. proc nextCommand {} {
  275.     global searchNoisily
  276.     set pos [getPos]
  277.     if {$pos < [maxPos]} then {
  278.         set searchResult [findCommand [expr $pos + 1] 1]
  279.         if { [string length $searchResult] } {
  280.             goto [lindex $searchResult 0]
  281.             return
  282.         } else {}
  283.     if { $searchNoisily } {beep}
  284.     message "next command not found"
  285. # Select the previous LaTeX command, but do not attempt to select
  286. # any associated argument.
  287. proc prevCommandSelect {} {
  288.     global searchNoisily
  289.     set pos [getPos]
  290.     if {$pos > 0} then {
  291.         set searchResult [findCommand [expr $pos - 1] 0]
  292.         if { [string length $searchResult] } {
  293.             eval select $searchResult
  294.             return
  295.         } else {}
  296.     if { $searchNoisily } {beep}
  297.     message "previous command not found"
  298. # Select the next LaTeX command, but do not attempt to select
  299. # any associated argument.
  300. proc nextCommandSelect {} {
  301.     global searchNoisily
  302.     set pos [getPos]
  303.     if {$pos < [maxPos]} then {
  304.         if { [isSelection] } then {
  305.             set pos [expr $pos + 1]
  306.         set searchResult [findCommand $pos 1]
  307.         if { [string length $searchResult] } {
  308.             eval select $searchResult
  309.             return
  310.         } else {}
  311.     if { $searchNoisily } {beep}
  312.     message "next command not found"
  313. # Find a LaTeX command with arguments in either direction.  It's up 
  314. # to the calling procedure to pass the starting position of the search.
  315. # (Handles everything but "\ " and commands whose arguments contain
  316. # embedded braces.)
  317. proc findCommandWithArgs {pos direction} {
  318.     set searchString {\\([^a-zA-Z\t\r]|[a-zA-Z]+\*?)(\[.*\])*({[^{}]*})*}
  319.     return [search -s -f $direction -r 1 -n $searchString $pos]
  320. # Select the previous LaTeX command and any associated arguments.
  321. proc prevCommandSelectWithArgs {} {
  322.     global searchNoisily
  323.     set pos [getPos]
  324.     if {$pos > 0} then {
  325.         set searchResult [findCommandWithArgs [expr $pos - 1] 0]
  326.         if { [string length $searchResult] } {
  327.             eval select $searchResult
  328.             return
  329.         } else {}
  330.     if { $searchNoisily } {beep}
  331.     message "previous command not found"
  332. # Select the next LaTeX command and any associated arguments.
  333. proc nextCommandSelectWithArgs {} {
  334.     global searchNoisily
  335.     set pos [getPos]
  336.     if {$pos < [maxPos]} then {
  337.         if { [isSelection] } then {
  338.             set pos [expr $pos + 1]
  339.         set searchResult [findCommandWithArgs $pos 1]
  340.         if { [string length $searchResult] } {
  341.             eval select $searchResult
  342.             return
  343.         } else {}
  344.     if { $searchNoisily } {beep}
  345.     message "next command not found"
  346. # Find a LaTeX sectioning command in either direction.  It's up to 
  347. # the calling procedure to pass the starting position of the search.
  348. proc findSection {pos direction} {
  349.     global funcExprAlt
  350.     return [search -s -f $direction -r 1 -n $funcExprAlt $pos]
  351. # Select the previous LaTeX sectioning command.
  352. proc prevSection {} {
  353.     global searchNoisily
  354.     set pos [getPos]
  355.     if {$pos > 0} then {
  356.         set searchResult [findSection [expr $pos - 1] 0]
  357.         if { [string length $searchResult] } {
  358.             eval select $searchResult
  359.             return
  360.         } else {}
  361.     if { $searchNoisily } {beep}
  362.     message {previous section not found}
  363. # Select the next LaTeX sectioning command.
  364. proc nextSection {} {
  365.     global searchNoisily
  366.     set pos [getPos]
  367.     if {$pos < [maxPos]} then {
  368.         if { [isSelection] } then {
  369.             set pos [expr $pos + 1]
  370.         set searchResult [findSection $pos 1]
  371.         if { [string length $searchResult] } {
  372.             eval select $searchResult
  373.             return
  374.         } else {}
  375.     if { $searchNoisily } {beep}
  376.     message {next section not found}
  377. proc prevSectionSelect {} {
  378.     global searchNoisily
  379.     set pos [getPos]
  380.     if {$pos > 0} then {
  381.         set searchResult [findSection [expr $pos - 1] 0]
  382.         if { [string length $searchResult] } {
  383.             set begPos [lindex $searchResult 0]
  384.             set searchPos [expr [lindex $searchResult 1] + 1]
  385.             set searchResult [findSection $searchPos 1]
  386.             if { [string length $searchResult] } {
  387.                 set endPos [lindex $searchResult 0]
  388.             } else {
  389.                 set searchResult [search -s -f 1 -r 0 -n "\\end{document}" $searchPos]
  390.                 set endPos [lindex $searchResult 0]
  391.             select $begPos $endPos
  392.             return
  393.         } else {}
  394.     if { $searchNoisily } {beep}
  395.     message {previous section not found}
  396. # Select the next LaTeX sectioning command.
  397. proc nextSectionSelect {} {
  398.     global searchNoisily
  399.     set pos [getPos]
  400.     if {$pos < [maxPos]} then {
  401.         if { [isSelection] } then {
  402.             set pos [expr $pos + 1]
  403.         set searchResult [findSection $pos 1]
  404.         if { [string length $searchResult] } {
  405.             set begPos [lindex $searchResult 0]
  406.             set searchPos [expr [lindex $searchResult 1] + 1]
  407.             set searchResult [findSection $searchPos 1]
  408.             if { [string length $searchResult] } {
  409.                 set endPos [lindex $searchResult 0]
  410.             } else {
  411.                 set searchResult [search -s -f 1 -r 0 -n "\\end{document}" $searchPos]
  412.                 set endPos [lindex $searchResult 0]
  413.             select $begPos $endPos
  414.             return
  415.         } else {}
  416.     if { $searchNoisily } {beep}
  417.     message {next section not found}
  418. # Find a LaTeX subsectioning command in either direction.  It's up to 
  419. # the calling procedure to pass the starting position of the search.
  420. proc findSubsection {pos direction} {
  421.     global funcExpr
  422.     return [search -s -f $direction -r 1 -n $funcExpr $pos]
  423. proc prevSubsection {} {
  424.     global searchNoisily
  425.     set pos [getPos]
  426.     if {$pos > 0} then {
  427.         set searchResult [findSubsection [expr $pos - 1] 0]
  428.         if { [string length $searchResult] } {
  429.             eval select $searchResult
  430.             return
  431.         } else {}
  432.     if { $searchNoisily } {beep}
  433.     message {previous (sub)*section not found}
  434. # Select the next LaTeX sectioning command.
  435. proc nextSubsection {} {
  436.     global searchNoisily
  437.     set pos [getPos]
  438.     if {$pos < [maxPos]} then {
  439.         if { [isSelection] } then {
  440.             set pos [expr $pos + 1]
  441.         set searchResult [findSubsection $pos 1]
  442.         if { [string length $searchResult] } {
  443.             eval select $searchResult
  444.             return
  445.         } else {}
  446.     if { $searchNoisily } {beep}
  447.     message {next (sub)*section not found}
  448. proc prevSubsectionSelect {} {
  449.     global searchNoisily
  450.     set pos [getPos]
  451.     if {$pos > 0} then {
  452.         set searchResult [findSubsection [expr $pos - 1] 0]
  453.         if { [string length $searchResult] } {
  454.             set begPos [lindex $searchResult 0]
  455.             set endPos [lindex $searchResult 1]
  456.             set searchPos [expr $endPos + 1]
  457.             set commandName [extractCommandName [getText $begPos $endPos]]
  458.             if {[string match {section*} $commandName]} then {
  459.                 set searchResult [findSection $searchPos 1]
  460.             } else {
  461.                 set searchResult [findSubsection $searchPos 1]
  462.             if { [string length $searchResult] } {
  463.                 set endPos [lindex $searchResult 0]
  464.             } else {
  465.                 set searchResult [search -s -f 1 -r 0 -n "\\end{document}" $searchPos]
  466.                 set endPos [lindex $searchResult 0]
  467.             select $begPos $endPos
  468.             return
  469.         } else {}
  470.     if { $searchNoisily } {beep}
  471.     message {previous (sub)*section not found}
  472. # Select the next LaTeX sectioning command.
  473. proc nextSubsectionSelect {} {
  474.     global searchNoisily
  475.     set pos [getPos]
  476.     if {$pos < [maxPos]} then {
  477.         if { [isSelection] } then {
  478.             set pos [expr $pos + 1]
  479.         set searchResult [findSubsection $pos 1]
  480.         if { [string length $searchResult] } {
  481.             set begPos [lindex $searchResult 0]
  482.             set endPos [lindex $searchResult 1]
  483.             set searchPos [expr $endPos + 1]
  484.             set commandName [extractCommandName [getText $begPos $endPos]]
  485.             if {[string match {section*} $commandName]} then {
  486.                 set searchResult [findSection $searchPos 1]
  487.             } else {
  488.                 set searchResult [findSubsection $searchPos 1]
  489.             if { [string length $searchResult] } {
  490.                 set endPos [lindex $searchResult 0]
  491.             } else {
  492.                 set searchResult [search -s -f 1 -r 0 -n "\\end{document}" $searchPos]
  493.                 set endPos [lindex $searchResult 0]
  494.             select $begPos $endPos
  495.             return
  496.         } else {}
  497.     if { $searchNoisily } {beep}
  498.     message {next (sub)*section not found}
  499. proc gotoTabStop {dirIndicator} {
  500.     set pos [getPos]
  501.     if {$dirIndicator} then {
  502.         if {$pos == [maxPos]} {return 0}
  503.     } else {
  504.         if {$pos == 0} {
  505.             set pos [expr $pos - 1]
  506.             return 0
  507.     set searchResult [search -s -n -f $dirIndicator -m 0 -i 1 -r 0 {
  508. } $pos]
  509.     if {[string length $searchResult]} then {
  510.         goto [lindex $searchResult 0]
  511.         return 1
  512.     } else {
  513.         return 0
  514. proc nextTabStop {} {
  515.     global searchNoisily
  516.     set forward 1
  517.     if {[gotoTabStop $forward]} then {
  518.         deleteChar
  519.     } else {
  520.         if {$searchNoisily} {beep}
  521.         message "tab stop not found"
  522. proc prevTabStop {} {
  523.     global searchNoisily
  524.     set forward 0
  525.     if {[gotoTabStop $forward]} then {
  526.         deleteChar
  527.     } else {
  528.         if {$searchNoisily} {beep}
  529.         message "tab stop not found"
  530. # Goto the nth tab stop.  A nonzero argument is non-interactive
  531. # (for use in Tcl procs) and not validated.
  532. proc nthTabStop {{numTabStops 0}} {
  533.     global searchNoisily promptNoisily useStatusBar
  534.     if {$numTabStops == 0} then {
  535.         if {$promptNoisily && $useStatusBar} {beep}
  536.         catch {sPrompt "How many tab stops?" "3"} numTabStops
  537.         if {$numTabStops == "cancel" || $numTabStops == 0} then {
  538.             return
  539.         } elseif {![isInteger $numTabStops]} then {
  540.             beep
  541.             message "invalid input:  integer required"
  542.             return
  543.     set currentPos [getPos]
  544.     if {$numTabStops > 0} {set forward 1} {set forward 0}
  545.     set maxits [expr abs($numTabStops)]
  546.     if {![gotoTabStop $forward]} then {
  547.         if {$searchNoisily} {beep}
  548.         message "tab stop not found"
  549.         goto $currentPos
  550.         return
  551.     for {set i 1} {$i < $maxits} {incr i} {
  552.         if {$forward} {forwardChar} {backwardChar}
  553.         if {![gotoTabStop $forward]} then {
  554.             if {$searchNoisily} {beep}
  555.             message "tab stop not found"
  556.             goto $currentPos
  557.             return
  558.     deleteChar
  559. #--------------------------------------------------------------------------
  560. # Utilities:
  561. #--------------------------------------------------------------------------
  562. # A keyboard-bound method of accessing menu commands.  Assumes the 
  563. # existence of two procs: 1) a proc called 'get___Menu', which 
  564. # returns the menu to be processed; and 2) a proc called '___MenuItem',
  565. # which filters menu items.  For example, in latex.tcl there are procs
  566. # called 'getLaTeXMenu' and 'LaTeXMenuItem' (see latexMenu.tcl).  To 
  567. # choose a command from the LaTeX menu, execute 'chooseCommand LaTeX' 
  568. # from the Tcl shell, or from within a proc.
  569. proc chooseCommand {mode {men {}} {level 1}} {
  570.     watchCursor
  571.     # If the first time through, get the menu:
  572.     if {![string length $men]} {
  573.         if {$level == 1} {
  574.             set men    [get${mode}Menu]
  575.         } else {
  576.             error "empty submenu"
  577.     # Process the menu:
  578.     foreach    item $men {
  579.         regsub -all {[<!/].} $item {} item
  580.         regsub -all {
  581. }    $item {} item
  582.         lappend    menOut $item
  583.         if {[string match "menu*" $item]} {
  584.             if {[set ind [lsearch $item {-n}]] >= 0} {
  585.                 lappend    top "[lindex $item [incr    ind]]:"
  586.         } elseif {![string match "(*" $item]} {
  587.             lappend    top $item
  588.     # Present the menu items to the user:
  589.     set res    [listpick -p "$mode menu (level $level):" $top]
  590.     # Either execute a command or recurse on a submenu:
  591.     if {[lsearch $menOut $res] >= 0} {
  592.         ${mode}MenuItem dummy    $res
  593.     } else {
  594.         set res [string trimright $res {:}]
  595.         foreach    item $menOut {
  596.             if {[set ind [lsearch $item $res]] >= 0} {
  597.                 return [chooseCommand $mode [lindex $item end] [incr level]]
  598. proc insertLiteralTab {} {
  599.     if {[isSelection]} then {
  600.         deleteSelection
  601.     insertText "\t"
  602. proc insertTabStop {} {
  603.     if {[isSelection]} then {
  604.         deleteSelection
  605.     insertText "
  606. # Removes all tab stops from the current selection (if there is one) 
  607. # or the current document, maintaining the cursor position in the 
  608. # latter case.
  609. proc deleteTabStops {} {
  610.     global searchNoisily
  611.     watchCursor
  612.     set subs1 0; set subs2 0; set subs3 0
  613.     set pos [getPos]
  614.     if {[set start $pos] == [set end [selEnd]]} {
  615.         set messageString "document"
  616.         set start 0
  617.         set end [maxPos]
  618.         set text1 [getText $start $pos]
  619.         set subs1 [regsub -all {
  620. } $text1 {} text1]
  621.         set text2 [getText $pos $end]
  622.         set subs2 [regsub -all {
  623. } $text2 {} text2]
  624.         append text $text1 $text2
  625.     } else {
  626.         set messageString "selection"
  627.         set text [getText $start $end]
  628.         set subs3 [regsub -all {
  629. } $text {} text]
  630.     if {$subs1 || $subs2 || $subs3} then {
  631.         replaceText $start $end $text
  632.         if {$messageString == "document"} then {
  633.             goto [expr $pos - $subs1]
  634.         } else {
  635.             set end [getPos]
  636.             select $start $end
  637.         set subs [expr $subs1 + $subs2 + $subs3]
  638.         message "$subs tab stops removed from $messageString"
  639.     } else {
  640.         if {$searchNoisily} {beep}
  641.         message "no tab stops found in $messageString"
  642. # Delete all unnecessary comments from the current document:
  643. proc deleteComments {} {
  644.     case [askyesno "Warning!  This operation can not be undone.  \
  645.                     Continue anyway?"] in {
  646.         "yes" {}
  647.         "no" { return }
  648.     replaceString {}
  649.     eval select [search -f 1 -r 1 -i 1 -m 0 -- {^[ \t]*%.*\r} 0]
  650.     replaceAll
  651.     replaceString {}
  652.     eval select [search -f 1 -r 1 -i 1 -m 0 -- {[ \t]+%.*} 0]
  653.     replaceAll
  654.     replaceString {\1%}
  655.     eval select [search -f 1 -r 1 -i 1 -m 0 -- {([^\\](\\\\)*)%.*} 0]
  656.     replaceAll
  657. # Converts all straight quotes to their TeX equivalents.
  658. proc convertQuotes {} {
  659.     global searchNoisily
  660.     message "working
  661.     watchCursor
  662.     set messageString "selection"
  663.     if {[set start [getPos]] == [set end [selEnd]]} {
  664.         set messageString "document"
  665.         set start 0
  666.         set end [maxPos]
  667.     set text [getText $start $end]
  668.     # Convert all left double quotes:
  669.     set convert1 [regsub -all "\(\^\|\[\ \r\t\(\[\{\]\)\"" $text {\1``} text]
  670.     # Convert all right double quotes:
  671.     set convert2 [regsub -all "\(\[\^\\\\\]\)\"" $text {\1''} text]
  672.     # Convert all left single quotes:
  673.     set convert3 [regsub -all "\(\^\|\[\ \r\t\(\[\{\]\)\'" $text {\1`} text]
  674.     if {$convert1 || $convert2 || $convert3} then {
  675.         replaceText $start $end $text
  676.         message "all quotes in $messageString converted"
  677.     } else {
  678.         if {$searchNoisily} {beep}
  679.         message "no quotes found in $messageString"
  680. # Returns true if the argument contains non-literal double dollar
  681. # signs, and false otherwise.
  682. proc containsDoubleDollarSigns {text} {
  683.     return [regexp {(^|[^\\])\$\$} $text]
  684. # Converts all $$...$$ pairs to \[...\] and returns the number of such 
  685. # pairs converted.  If the dollar signs are unbalanced, does nothing 
  686. # and returns -1.
  687. proc convertDoubleDollarSigns {} {
  688.     watchCursor
  689.     set messageString "selection"
  690.     if {[set start [getPos]] == [set end [selEnd]]} {
  691.         set messageString "document"
  692.         set start 0
  693.         set end [maxPos]
  694.     set text [getText $start $end]
  695.     set subs [regsub -all {(^|[^\\])\$\$([^$]*)\$\$} $text {\1\\[\2\\]} text]
  696.     if {[containsDoubleDollarSigns $text]} then {return -1}
  697.     if {$subs} then {
  698.         replaceText $start $end $text
  699.     return [expr $subs]
  700. # Returns true if the argument contains a non-literal dollar sign,
  701. # and false otherwise.
  702. proc containsSingleDollarSign {text} {
  703.     return [regexp {(^|[^\\])\$} $text]
  704. # Converts all $...$ pairs to \(...\), maintains the cursor position, 
  705. # and returns the number of such pairs converted.  If the dollar signs 
  706. # are unbalanced, does nothing and returns -1.
  707. proc convertSingleDollarSigns {} {
  708.     watchCursor
  709.     set subs1 0; set subs2 0; set subs3 0
  710.     set pos [getPos]; set pos2 $pos
  711.     if {[set start $pos] == [set end [selEnd]]} {
  712.         set isSelection 0
  713.         set start 0
  714.         set end [maxPos]
  715.         set text1 [getText $start $pos]
  716.         set subs1 [regsub -all {(^|[^\\])\$([^$]*)\$} $text1 {\1\\(\2\\)} text1]
  717.         # Is there a dollar sign left over?  If so, search backward for this
  718.         # dollar sign and prepare to do a substitution on the text to the right
  719.         # of this dollar sign.
  720.         if {[containsSingleDollarSign $text1]} then {
  721.             set searchString {[^\\]\$}
  722.             set searchResult [search -s -n -f 0 -m 0 -i 1 -r 1 $searchString [expr $pos-1]]
  723.             set pos2 [lindex $searchResult 0]
  724.             set text1 [string range $text1 0 [expr $pos2 + (2 * $subs1)]]
  725.             set pos [expr $pos + 2]
  726.         set text2 [getText $pos2 $end]
  727.         set subs2 [regsub -all {(^|[^\\])\$([^$]*)\$} $text2 {\1\\(\2\\)} text2]
  728.         # Is there a dollar sign left over?  If so, it's unbalanced.
  729.         if {[containsSingleDollarSign $text2]} then {return -1}
  730.         append text $text1 $text2
  731.     } else {
  732.         set isSelection 1
  733.         set text [getText $start $end]
  734.         set subs3 [regsub -all {(^|[^\\])\$([^$]*)\$} $text {\1\\(\2\\)} text]
  735.         # Is there a dollar sign left over?  If so, it's unbalanced.
  736.         if {[containsSingleDollarSign $text]} then {return -1}
  737.     if {$subs1 || $subs2 || $subs3} then {
  738.         replaceText $start $end $text
  739.         # If there is a selection, just put it back.  Otherwise, adjust the
  740.         # cursor position based on the number of substitutions.
  741.         if {$isSelection} then {
  742.             set end [getPos]
  743.             select $start $end
  744.         } else {
  745.             goto [expr $pos + (2 * $subs1)]
  746.     return [expr $subs1 + $subs2 + $subs3]
  747. proc convertDollarSigns {} {
  748.     global searchNoisily
  749.     if {[isSelection]} then {
  750.         set messageString "selection"
  751.     } else {
  752.         set messageString "document"
  753.     set subs2 [convertDoubleDollarSigns]
  754.     if {$subs2 == -1} then {
  755.         beep
  756.         alertnote "unmatched double dollar signs in $messageString"
  757.     } else {
  758.         set subs1 [convertSingleDollarSigns]
  759.         if {$subs1 == -1} then {
  760.             beep
  761.             alertnote "unmatched single dollar sign in $messageString"
  762.         } elseif {$subs1 == 0 && $subs2 == 0} then {
  763.             if {$searchNoisily} {beep}
  764.             message "no dollar signs found in $messageString"
  765.         } else {
  766.             message "$subs1 pairs of \$...\$ and $subs2 pairs of \$\$...\$\$ removed from $messageString"
  767. proc removeAuxiliaryFiles {} {
  768.     set word ""
  769.     set removeSilently 0
  770.     set currentWin [lindex [winNames -f] 0]
  771.     set currentDir [file dirname $currentWin]
  772.     set currentDoc [file tail $currentWin]
  773.     set docBasename [file rootname $currentDoc]
  774. #     set docExtension [file extension $currentDoc]
  775.     set extensions {.aux .bbl .dvi .glo .idx .ind .lof .log .lot \
  776.               .toc .blg .clg .ilg .ps}
  777.     foreach ext $extensions {
  778.         message "Checking for *$ext files
  779.         set files [glob -nocomplain "$currentDir:*$ext"]
  780.         foreach file $files {
  781.             set word " more"
  782.             if {$removeSilently} {
  783.                 if {[catch {rm "$currentDir:*$ext"}]} then {
  784.                     alertnote "not all \"*$ext\" files deleted"
  785.                 }
  786.                 break
  787.             } else {
  788.                 message ""
  789.                 set filename [file tail $file]
  790.                 case [buttonAlert "Remove \"$filename\"?" "yes" "no" {rm ext} {rm all} "cancel"] in {
  791.                     "yes" {
  792.                         message "Removing $filename
  793.                         if {[catch {removeFile "$currentDir:$filename"}]} then {
  794.                             alertnote "\"$filename\" not deleted"
  795.                         } else {
  796.                             message $filename
  797.                         }
  798.                     }
  799.                     "no" {}
  800.                     "{rm ext}" {
  801.                         if {[catch {rm "$currentDir:*$ext"}]} then {
  802.                             alertnote "not all \"*$ext\" files deleted"
  803.                         }
  804.                         break
  805.                     }
  806.                     "{rm all}" {
  807.                         if {[catch {rm "$currentDir:*$ext"}]} then {
  808.                             alertnote "not all \"*$ext\" files deleted"
  809.                         }
  810.                         set removeSilently 1
  811.                         break
  812.                     }
  813.                     "cancel" {return}
  814.                 }
  815.     message "No$word files found"
  816. #############################################################################
  817. # Paragraph Mode Macros
  818. #############################################################################
  819. #--------------------------------------------------------------------------
  820. # Documents:
  821. #--------------------------------------------------------------------------
  822. proc letter {} {
  823.     set    preamble "\r\\address\{%\r"
  824.     append preamble "    
  825.     \\\\    % insert your name here\r"
  826.     append preamble "    
  827.     \\\\    % insert your address here\r"
  828.     append preamble "    
  829.     \\\\    % insert more address here\r"
  830.     append preamble "    
  831.           % insert city-state-zip here\r"
  832.     append preamble "\}\r\r"
  833.     append preamble "\\date\{
  834. \}  % optional\r"
  835.     append preamble "\\signature\{
  836. \}\r\r"
  837.     set    body "\r\\begin\{letter\}\{%\r"
  838.     append body "    
  839.     \\\\    % insert addressee's name here\r"
  840.     append body "    
  841.     \\\\    % insert addressee's address here\r"
  842.     append body "    
  843.     \\\\    % insert more address here\r"
  844.     append body "    
  845.           % insert addressee's city-state-zip here\r"
  846.     append body "\}\r\r"
  847.     append body "\\opening\{Dear 
  848. ,\}\r\r"
  849.     if {[isEmptyFile]} then {
  850.         append body "% BODY OF LETTER\r"
  851.         append body "
  852. \r\r"
  853.     } else {
  854.         if {[isDocumentSelected]} then {
  855.             set text [getSelect]
  856. #             deleteText 0 [maxPos]
  857.             append body "$text\r"
  858.         } else {
  859.             alertnote "nonempty file:  delete text or \'Select All\'\
  860.                 from the Edit menu"
  861.             return
  862.     append body "\\closing\{Sincerely,\}\r\r"
  863.     append body "\\encl\{
  864. \}\r"
  865.     append body "\\cc\{
  866. \}\r\r"
  867.     append body "\\end\{letter\}\r\r"
  868.     insertDocument "letter" $preamble $body
  869.     nextTabStop
  870.     message "enter option (or leave blank)"
  871. proc article {} {
  872.     wrapDocument "article"
  873.     nextTabStop
  874.     message "enter option (or leave blank)"
  875. proc report {} {
  876.     wrapDocument "report"
  877.     nextTabStop
  878.     message "enter option (or leave blank)"
  879. proc book {} {
  880.     wrapDocument "book"
  881.     nextTabStop
  882.     message "enter option (or leave blank)"
  883. proc slides {} {
  884.     wrapDocument "slides"
  885.     nextTabStop
  886.     message "enter option (or leave blank)"
  887. proc generic {} {
  888.     catch {prompt "What documentclass?" "article"} documentType
  889.     if {$documentType != "cancel"} then {
  890.         wrapDocument "$documentType" 
  891.         nextTabStop
  892.         message "enter option (or leave blank)"
  893. proc getOption {} {
  894.     catch {prompt "Choose an option:" "11pt" "" "10pt" "11pt" "12pt" "(-" \
  895.             "letterpaper" "legalpaper" "executivepaper" "a4paper" "a5paper" \
  896.             "b5paper" "(-" "landscape" "(-" "final" "draft" "(-" \
  897.             "oneside" "twoside" "(-" "openright" "openany" "(-" \
  898.             "onecolumn" "twocolumn" "(-" "notitlepage" "titlepage" \
  899.                   "openbib" "(-" "leqno" "(-" "fleqn"} optionName
  900.     if {$optionName != "cancel"} then {
  901.         return $optionName
  902.     } else {
  903.         return ""
  904. proc insertOption {option} {
  905.     global searchNoisily
  906.     set searchString {\\documentclass}
  907.     set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  908.     if {[llength $searchResult] == 0} then {
  909.         if {$searchNoisily} {beep}
  910.         message "can\'t find \\documentclass"
  911.     } else {
  912.         set nextCharPos [lindex $searchResult 1]
  913.         goto $nextCharPos
  914.         set nextChar [lookAt $nextCharPos]
  915.         if {$nextChar == "\["} then {
  916.             forwardChar
  917.             insertText $option
  918.             if {[lookAt [getPos]] != "\]"} then {
  919.                 insertText ","
  920.         } elseif {$nextChar == "\{"} then {
  921.             insertText "\[$option\]"
  922.         } else {
  923.             alertnote "unrecognizable \\documentclass statement"
  924. proc options {} {
  925.     set option [getOption]
  926.     if {$option != ""} then {
  927.         insertOption $option
  928. proc getPackage {} {
  929.     catch {prompt "Choose a package:" "latexsym" "" \
  930.                   "alltt" "amstex" "babel" "color" \
  931.                   "graphics" "graphpap" "ifthen" "latexsym" "makeidx" \
  932.                   "pict2e" "showidx"} packageName
  933.     if {$packageName != "cancel"} then {
  934.         return $packageName
  935.     } else {
  936.         return ""
  937. proc insertPackage {package} {
  938.     global searchNoisily
  939.     set begPos [getPos]
  940.     set endPos [selEnd]
  941.     append searchString {\\usepackage\{.*} $package {.*\}}
  942.     set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  943.     if {[llength $searchResult] == 0} then {
  944.         set searchString {\\documentclass(\[.*\])?\{.*\}}
  945.         set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  946.         if {[llength $searchResult] == 0} then {
  947.             if {$searchNoisily} {beep}
  948.             message "can't find \\documentclass"
  949.         } else {
  950.             goto [lindex $searchResult 1]
  951.             set txt "\r\\usepackage\{$package\}"
  952.             set offset [string length $txt]
  953.             set begPos [expr $begPos + $offset]
  954.             set endPos [expr $endPos + $offset]
  955.             insertText $txt
  956.             select $begPos $endPos
  957.     } else {
  958.         if {$searchNoisily} {beep}
  959.         message "$package package already loaded"
  960. proc packages {} {
  961.     set package [getPackage]
  962.     if {$package != ""} then {
  963.         insertPackage $package
  964. proc usepackage {} {
  965.     if {[wrapObject "\\usepackage\[
  966. \]{" "}
  967. "]} then {
  968.         message "type the package options"
  969.     } else {
  970.         message "type the package options and then the package name"
  971. proc filecontents {} {
  972.     global searchNoisily
  973.     set searchString {\\documentclass}
  974.     set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  975.     if {[llength $searchResult] == 0} then {
  976.         if {$searchNoisily} {beep}
  977.         message "can\'t find \\documentclass"
  978.         return
  979.     } else {
  980.         set prompt "File to be included:"
  981.         if {[catch {getfile $prompt} path]} then {
  982.             return
  983.         } else {
  984.             set fd [open $path]
  985.             set text [read $fd]
  986.             close $fd
  987.             regsub -all "\xa" $text "\xd" text
  988.             goto 0
  989.             set envName "filecontents"
  990.             set envArg "{[file tail $path]}"
  991.             replaceText 0 0 [buildEnvironment $envName $envArg "$text\r" "\r\r"]
  992.             goto 0
  993.             message "file included"
  994. #--------------------------------------------------------------------------
  995. # Page Layout:
  996. #--------------------------------------------------------------------------
  997. proc maketitle {} {
  998.     global searchNoisily
  999.     set searchString {\\document(class|style)(\[.*\])?\{.*\}}
  1000.     set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  1001.     if {[llength $searchResult] == 0} then {
  1002.         if {$searchNoisily} {beep}
  1003.         message "can\'t find \\documentclass or \\documentstyle"
  1004.     } else {
  1005.         set searchPos [lindex $searchResult 1]
  1006.         set searchString {\\begin\{document\}}
  1007.         set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 $searchString $searchPos]
  1008.         if {[llength $searchResult] == 0} then {
  1009.             if {$searchNoisily} {beep}
  1010.             message "can\'t find \\begin\{document\}"
  1011.         } else {
  1012.             goto [lindex $searchResult 1]
  1013.             set currentPos [getPos]
  1014.             set txt "\r\r% Definition of title page:"
  1015.             append txt "\r\\title\{"
  1016.             append txt "\r\t
  1017. \r\}"
  1018.             append txt "\r\\author\{"
  1019.             append txt "\r\t
  1020. \t% insert author(s) here"
  1021.             append txt "\r\}"
  1022.             append txt "\r\\date\{
  1023. \}\t% optional"
  1024.             append txt "\r\r\\maketitle"
  1025.             insertText $txt
  1026.             goto $currentPos
  1027.             nextTabStop
  1028.             message "insert title"
  1029. proc abstract {} { doWrapEnvironment "abstract" }
  1030. proc titlepage {} { doWrapEnvironment "titlepage" }
  1031. proc getPagestyle {} {
  1032.     catch {prompt "Choose a pagestyle:" "plain" "" "plain" "empty" \
  1033.                   "headings" "myheadings"} pagestyleName
  1034.     if {$pagestyleName != "cancel"} then {
  1035.         return $pagestyleName
  1036.     } else {
  1037.         return ""
  1038. proc pagestyle {} {
  1039.     set pagestyleName [getPagestyle]
  1040.     if {$pagestyleName != ""} then {
  1041.         openingCarriageReturn
  1042.         insertObject "\\pagestyle\{$pagestyleName\}"
  1043.         closingCarriageReturn
  1044. proc thispagestyle {} {
  1045.     set pagestyleName [getPagestyle]
  1046.     if {$pagestyleName != ""} then {
  1047.         openingCarriageReturn
  1048.         insertObject "\\thispagestyle\{$pagestyleName\}"
  1049.         closingCarriageReturn
  1050. proc getPagenumberingStyle {} {
  1051.     catch {prompt "Choose a pagenumbering style:" "arabic" "" "arabic" \
  1052.                   "roman" "Roman" "alph" "Alph"} pagenumberingStyle
  1053.     if {$pagenumberingStyle != "cancel"} then {
  1054.         return $pagenumberingStyle
  1055.     } else {
  1056.         return ""
  1057. proc pagenumbering {} {
  1058.     set pagenumberingStyle [getPagenumberingStyle]
  1059.     if {$pagenumberingStyle != ""} then {
  1060.         openingCarriageReturn
  1061.         insertObject "\\pagenumbering\{$pagenumberingStyle\}"
  1062.         closingCarriageReturn
  1063. proc twocolumn {} {
  1064.     openingCarriageReturn
  1065.     insertObject "\\twocolumn"
  1066.     closingCarriageReturn
  1067. proc onecolumn {} {
  1068.     openingCarriageReturn
  1069.     insertObject "\\onecolumn"
  1070.     closingCarriageReturn
  1071. #--------------------------------------------------------------------------
  1072. # Sectioning:
  1073. #--------------------------------------------------------------------------
  1074. proc part {} {
  1075.     if {[wrapObject "\\part{" "}
  1076. "]} then {
  1077.         message "don't forget the label"
  1078.     } else {
  1079.         message "type the part name and don't forget the label"
  1080. proc chapter {} {
  1081.     if {[wrapObject "\\chapter{" "}
  1082. "]} then {
  1083.         message "don't forget the label"
  1084.     } else {
  1085.         message "type the chapter name and don't forget the label"
  1086. proc section {} {
  1087.     if {[wrapObject "\\section{" "}
  1088. "]} then {
  1089.         message "don't forget the label"
  1090.     } else {
  1091.         message "type the section name and don't forget the label"
  1092. proc subsection {} {
  1093.     if {[wrapObject "\\subsection{" "}
  1094. "]} then {
  1095.         message "don't forget the label"
  1096.     } else {
  1097.         message "type the subsection name and don't forget the label"
  1098. proc subsubsection {} {
  1099.     if {[wrapObject "\\subsubsection{" "}
  1100. "]} then {
  1101.         message "don't forget the label"
  1102.     } else {
  1103.         message "type the subsubsection name and don't forget the label"
  1104. proc paragraph {} {
  1105.     if {[wrapObject "\\paragraph{" "}
  1106. "]} then {
  1107.         message "don't forget the label"
  1108.     } else {
  1109.         message "type the paragraph name and don't forget the label"
  1110. proc subparagraph {} {
  1111.     if {[wrapObject "\\subparagraph{" "}
  1112. "]} then {
  1113.         message "don't forget the label"
  1114.     } else {
  1115.         message "type the subparagraph name and don't forget the label"
  1116. proc appendix {} {insertObject "\\appendix"}
  1117. #--------------------------------------------------------------------------
  1118. # Text Style:
  1119. #--------------------------------------------------------------------------
  1120. proc emph {} {
  1121.     if {[wrapObject "\\emph{" "}
  1122. "]} then {
  1123.         message "selected text has been emphasized"
  1124.     } else {
  1125.         message "enter text to be emphasized"
  1126. proc textup {} {
  1127.     if {[wrapObject "\\textup{" "}
  1128. "]} then {
  1129.         message "selected text has upright shape"
  1130.     } else {
  1131.         message "enter text to have upright shape"
  1132. proc textit {} {
  1133.     if {[wrapObject "\\textit{" "}
  1134. "]} then {
  1135.         message "selected text has italic shape"
  1136.     } else {
  1137.         message "enter text to have italic shape"
  1138. proc textsl {} {
  1139.     if {[wrapObject "\\textsl{" "}
  1140. "]} then {
  1141.         message "selected text has slanted shape"
  1142.     } else {
  1143.         message "enter text to have slanted shape"
  1144. proc textsc {} {
  1145.     if {[wrapObject "\\textsc{" "}
  1146. "]} then {
  1147.         message "selected text has small caps shape"
  1148.     } else {
  1149.         message "enter text to have small caps shape"
  1150. proc textmd {} {
  1151.     if {[wrapObject "\\textmd{" "}
  1152. "]} then {
  1153.         message "selected text has been set in medium series"
  1154.     } else {
  1155.         message "enter text to be set in medium series"
  1156. proc textbf {} {
  1157.     if {[wrapObject "\\textbf{" "}
  1158. "]} then {
  1159.         message "selected text has been set in bold series"
  1160.     } else {
  1161.         message "enter text to be set in bold series"
  1162. proc textrm {} {
  1163.     if {[wrapObject "\\textrm{" "}
  1164. "]} then {
  1165.         message "selected text has been set with roman family"
  1166.     } else {
  1167.         message "enter text to be set using roman family"
  1168. proc textsf {} {
  1169.     if {[wrapObject "\\textsf{" "}
  1170. "]} then {
  1171.         message "selected text has been set with sans serif family"
  1172.     } else {
  1173.         message "enter text to be set using sans serif family"
  1174. proc texttt {} {
  1175.     if {[wrapObject "\\texttt{" "}
  1176. "]} then {
  1177.         message "selected text has been set with typewriter family"
  1178.     } else {
  1179.         message "enter text to be set using typewriter family"
  1180. proc textnormal {} {
  1181.     if {[wrapObject "\\textnormal{" "}
  1182. "]} then {
  1183.         message "selected text has been set with normal style"
  1184.     } else {
  1185.         message "enter text to be set using normal style"
  1186. proc em {} {
  1187.     if {[wrapObject "{\\em " "}
  1188. "]} then {
  1189.         message "emphasized text set"
  1190.     } else {
  1191.         message "enter text to be emphasized"
  1192. proc upshape {} {
  1193.     if {[wrapObject "{\\upshape " "}
  1194. "]} then {
  1195.         message "text set in upright shape"
  1196.     } else {
  1197.         message "enter text to be set in upright shape"
  1198. proc itshape {} {
  1199.     if {[wrapObject "{\\itshape " "}
  1200. "]} then {
  1201.         message "text set in italics shape"
  1202.     } else {
  1203.         message "enter text to be set in italics shape"
  1204. proc slshape {} {
  1205.     if {[wrapObject "{\\slshape " "}
  1206. "]} then {
  1207.         message "text set in slanted shape"
  1208.     } else {
  1209.         message "enter text to be set in slanted shape"
  1210. proc scshape {} {
  1211.     if {[wrapObject "{\\scshape " "}
  1212. "]} then {
  1213.         message "text set in small caps shape"
  1214.     } else {
  1215.         message "enter text to be set in small caps shape"
  1216. proc mdseries {} {
  1217.     if {[wrapObject "{\\mdseries " "}
  1218. "]} then {
  1219.         message "text set in medium series"
  1220.     } else {
  1221.         message "enter text to be set in medium series"
  1222. proc bfseries {} {
  1223.     if {[wrapObject "{\\bfseries " "}
  1224. "]} then {
  1225.         message "text set in bold series"
  1226.     } else {
  1227.         message "enter text to be set in bold series"
  1228. proc rmfamily {} {
  1229.     if {[wrapObject "{\\rmfamily " "}
  1230. "]} then {
  1231.         message "text set in roman family"
  1232.     } else {
  1233.         message "enter text to be set in roman family"
  1234. proc sffamily {} {
  1235.     if {[wrapObject "{\\sffamily " "}
  1236. "]} then {
  1237.         message "text set in sans serif family"
  1238.     } else {
  1239.         message "enter text to be set in sans serif family"
  1240. proc ttfamily {} {
  1241.     if {[wrapObject "{\\ttfamily " "}
  1242. "]} then {
  1243.         message "text set in typewriter family"
  1244.     } else {
  1245.         message "enter text to be set in typewriter family"
  1246. proc normalfont {} {
  1247.     if {[wrapObject "{\\normalfont " "}
  1248. "]} then {
  1249.         message "text set in normal style"
  1250.     } else {
  1251.         message "enter text to be set in normal style"
  1252. #--------------------------------------------------------------------------
  1253. # Text Size:
  1254. #--------------------------------------------------------------------------
  1255. proc tiny {} {
  1256.     if {[wrapObject "{\\tiny " "}
  1257. "]} then {
  1258.         message "tiny text set"
  1259.     } else {
  1260.         message "enter tiny text"
  1261. proc scriptsize {} {
  1262.     if {[wrapObject "{\\scriptsize " "}
  1263. "]} then {
  1264.         message "scriptsize text set"
  1265.     } else {
  1266.         message "enter scriptsize text"
  1267. proc footnotesize {} {
  1268.     if {[wrapObject "{\\footnotesize " "}
  1269. "]} then {
  1270.         message "footnotesize text set"
  1271.     } else {
  1272.         message "enter footnotesize text"
  1273. proc small {} {
  1274.     if {[wrapObject "{\\small " "}
  1275. "]} then {
  1276.         message "small text set"
  1277.     } else {
  1278.         message "enter small text"
  1279. proc normalsize {} {
  1280.     if {[wrapObject "{\\normalsize " "}
  1281. "]} then {
  1282.         message "normalsize text set"
  1283.     } else {
  1284.         message "enter normalsize text"
  1285. proc large {} {
  1286.     if {[wrapObject "{\\large " "}
  1287. "]} then {
  1288.         message "large text set"
  1289.     } else {
  1290.         message "enter large text"
  1291. proc Large {} {
  1292.     if {[wrapObject "{\\Large " "}
  1293. "]} then {
  1294.         message "Large text set"
  1295.     } else {
  1296.         message "enter Large text"
  1297. proc LARGE {} {
  1298.     if {[wrapObject "{\\LARGE " "}
  1299. "]} then {
  1300.         message "LARGE text set"
  1301.     } else {
  1302.         message "enter LARGE text"
  1303. proc huge {} {
  1304.     if {[wrapObject "{\\huge " "}
  1305. "]} then {
  1306.         message "huge text set"
  1307.     } else {
  1308.         message "enter huge text"
  1309. proc Huge {} {
  1310.     if {[wrapObject "{\\Huge " "}
  1311. "]} then {
  1312.         message "Huge text set"
  1313.     } else {
  1314.         message "enter Huge text"
  1315. #--------------------------------------------------------------------------
  1316. # International:
  1317. #--------------------------------------------------------------------------
  1318. proc {
  1319. } {} {
  1320.     if {[wrapObject "\\`{" "}
  1321. "]} then {
  1322.         message "accent set"
  1323.     } else {
  1324.         message "enter single character"
  1325. proc {
  1326. } {} {
  1327.     if {[wrapObject "\\'{" "}
  1328. "]} then {
  1329.         message "accent set"
  1330.     } else {
  1331.         message "enter single character"
  1332. proc {
  1333. } {} {
  1334.     if {[wrapObject "\\^{" "}
  1335. "]} then {
  1336.         message "accent set"
  1337.     } else {
  1338.         message "enter single character"
  1339. proc {
  1340. } {} {
  1341.     if {[wrapObject "\\\"{" "}
  1342. "]} then {
  1343.         message "accent set"
  1344.     } else {
  1345.         message "enter single character"
  1346. proc {
  1347. } {} {
  1348.     if {[wrapObject "\\~{" "}
  1349. "]} then {
  1350.         message "accent set"
  1351.     } else {
  1352.         message "enter single character"
  1353. proc {
  1354. } {} {insertObject "\\c\{c\}"}
  1355. proc {
  1356. } {} {insertObject "\\c\{C\}"}
  1357. proc {
  1358. } {} {insertObject "\\oe"}
  1359. proc {
  1360. } {} {insertObject "\\OE"}
  1361. proc {
  1362. } {} {insertObject "\\ae"}
  1363. proc {
  1364. } {} {insertObject "\\AE"}
  1365. proc {
  1366. } {} {insertObject "\\aa"}
  1367. proc {
  1368. } {} {insertObject "\\AA"}
  1369. proc {
  1370. } {} {insertObject "\\o"}
  1371. proc {
  1372. } {} {insertObject "\\O"}
  1373. proc {
  1374. } {} {insertObject "\\ss"}
  1375. proc {
  1376. } {} {insertObject "?`"}
  1377. proc {
  1378. } {} {insertObject "!`"}
  1379. #--------------------------------------------------------------------------
  1380. # Environments:
  1381. #--------------------------------------------------------------------------
  1382. proc enumerate {} {
  1383.     global promptNoisily useStatusBar
  1384.     set envName "enumerate"
  1385.     if {$promptNoisily && $useStatusBar} {beep}
  1386.     catch {sPrompt "$envName:  how many items?" 3} numberItems
  1387.     if {$numberItems == "cancel"} then {
  1388.         return
  1389.     } elseif {![isPositiveInteger $numberItems]} then {
  1390.         beep
  1391.         message "invalid input:  unsigned, postive integer required"
  1392.         return
  1393.     if {$numberItems} then {
  1394.         set body "\t\\item  
  1395.         for {set i 1} {$i < $numberItems} {incr i} {
  1396.             append body "\r\r\t\\item  
  1397.         append body "\r"
  1398.     } else {
  1399.         set body "\t
  1400.     if {[insertEnvironment $envName "" $body]} then {
  1401.         nextTabStop
  1402.         message "type first item"
  1403. proc itemize {} {
  1404.     global promptNoisily useStatusBar
  1405.     set envName "itemize"
  1406.     if {$promptNoisily && $useStatusBar} {beep}
  1407.     catch {sPrompt "$envName:  how many items?" 3} numberItems
  1408.     if {$numberItems == "cancel"} then {
  1409.         return
  1410.     } elseif {![isPositiveInteger $numberItems]} then {
  1411.         beep
  1412.         message "invalid input:  unsigned, postive integer required"
  1413.         return
  1414.     if {$numberItems} then {
  1415.         set body "\t\\item  
  1416.         for {set i 1} {$i < $numberItems} {incr i} {
  1417.             append body "\r\r\t\\item  
  1418.         append body "\r"
  1419.     } else {
  1420.         set body "\t
  1421.     if {[insertEnvironment $envName "" $body]} then {
  1422.         nextTabStop
  1423.         message "type first item"
  1424. proc description {} {
  1425.     global promptNoisily useStatusBar
  1426.     set envName "description"
  1427.     if {$promptNoisily && $useStatusBar} {beep}
  1428.     catch {sPrompt "$envName:  how many items?" 3} numberItems
  1429.     if {$numberItems == "cancel"} then {
  1430.         return
  1431.     } elseif {![isPositiveInteger $numberItems]} then {
  1432.         beep
  1433.         message "invalid input:  unsigned, postive integer required"
  1434.         return
  1435.     if {$numberItems} then {
  1436.         set body "\t\\item\[
  1437.         for {set i 1} {$i < $numberItems} {incr i} {
  1438.             append body "\r\r\t\\item\[
  1439.         append body "\r"
  1440.     } else {
  1441.         set body "\t
  1442.     if {[insertEnvironment $envName "" $body]} then {
  1443.         nextTabStop
  1444.         message "type first item label"
  1445. proc thebibliography {} {
  1446.     global promptNoisily useStatusBar
  1447.     set envName "thebibliography"
  1448.     if {$promptNoisily && $useStatusBar} {beep}
  1449.     catch {sPrompt "$envName:  how many items?" 3} numberItems
  1450.     if {$numberItems == "cancel"} then {
  1451.         return
  1452.     } elseif {![isPositiveInteger $numberItems]} then {
  1453.         beep
  1454.         message "invalid input:  unsigned, postive integer required"
  1455.         return
  1456.     set arg "{9}"
  1457.     if {$numberItems} then {
  1458.         if {$numberItems > 9} then {set arg "{99}"}
  1459.         set body "\t\\bibitem{
  1460.         for {set i 1} {$i < $numberItems} {incr i} {
  1461.             append body "\r\r\t\\bibitem{
  1462.         append body "\r"
  1463.     } else {
  1464.         set body "\t
  1465.     if {[insertEnvironment $envName $arg $body]} then {
  1466.         set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 {(9)+} [getPos]]
  1467.         eval select $searchResult
  1468.         message "Change the length of the key field?"
  1469. proc slide {} { doWrapEnvironment "slide" }
  1470. proc overlay {} { doWrapEnvironment "overlay" }
  1471. proc note {} { doWrapEnvironment "note" }
  1472. proc figure {} {
  1473.     global useBoxMacro boxMacroName
  1474.     set envName "figure"
  1475.     set envArg "tbp"
  1476.     set arg "\[$envArg\]"
  1477.     set body ""
  1478.     if {$useBoxMacro} then {
  1479.         append body "\t\\centerline{\\$boxMacroName{
  1480. }}\r"
  1481.     append body "\t\\caption{
  1482.     append body "\t\\protect\\label{
  1483.     if {$useBoxMacro} then {
  1484.         if {![insertEnvironment $envName $arg $body]} then {return}
  1485.     } else {
  1486.         wrapEnvironment $envName $arg $body
  1487.     set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 "$envArg" [getPos]]
  1488.     eval select $searchResult
  1489.     message "Modify this argument?  (t=top; b=bottom; p=page; h=here; !=try harder)"
  1490. proc table {} {
  1491.     set envName "table"
  1492.     set envArg "tbp"
  1493.     # The following statement puts the caption at the top:
  1494.     set arg "\[$envArg\]\r[getIndentation [getPos]]\t\\caption{
  1495.     # The following two statements put the caption at the bottom:
  1496. #     set arg "\[$envArg\]"
  1497. #     set body "\t\\caption{
  1498.     append body "\t\\protect\\label{
  1499.     wrapEnvironment $envName $arg $body
  1500.     set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 "$envArg" [getPos]]
  1501.     eval select $searchResult
  1502.     message "Modify this argument?  (t=top; b=bottom; p=page; h=here; !=try harder)"
  1503. proc buildRow {jmax} {
  1504.     set txt "
  1505.     for {set j 1} {$j < $jmax} {incr j} {
  1506.         append txt " & 
  1507.     return $txt
  1508. proc tabular {} {
  1509.     global promptNoisily useStatusBar
  1510.     set envName "tabular"
  1511.     if {$promptNoisily && $useStatusBar} {beep}
  1512.     catch {sPrompt "$envName:  how many rows?" 3} numberRows
  1513.     if {$numberRows == "cancel"} then {
  1514.         return
  1515.     } elseif {![isPositiveInteger $numberRows]} then {
  1516.         beep
  1517.         message "invalid input:  unsigned, postive integer required"
  1518.         return
  1519.     if {$promptNoisily && $useStatusBar} {beep}
  1520.     catch {sPrompt "$envName:  how many columns?" 3} numberCols
  1521.     if {$numberCols == "cancel"} then {
  1522.         return
  1523.     } elseif {![isPositiveInteger $numberCols]} then {
  1524.         beep
  1525.         message "invalid input:  unsigned, postive integer required"
  1526.         return
  1527.     set arg "{|"
  1528.     for {set j 1} {$j <= $numberCols} {incr j} {
  1529.         append arg "c|"
  1530.     append arg "}"
  1531.     set body "\t\\hline\r"
  1532.     for {set i 1} {$i <= $numberRows} {incr i} {
  1533.         append body "\t[buildRow $numberCols]"
  1534.         append body "  \\\\\r\t\\hline\r"
  1535.     if {[insertEnvironment $envName $arg $body]} then {
  1536.         set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 {(c|\|)+} [getPos]]
  1537.         select [lindex $searchResult 0] [lindex $searchResult 1]
  1538.         message "Modify this argument?"
  1539. proc verbatim {} { doWrapEnvironment "verbatim" }
  1540. proc quote {} { doWrapEnvironment "quote" }
  1541. proc quotation {} { doWrapEnvironment "quotation" }
  1542. proc verse {} { doWrapEnvironment "verse" }
  1543. proc flushleft {} { doWrapEnvironment "flushleft" }
  1544. proc center {} { doWrapEnvironment "center" }
  1545. proc flushright {} { doWrapEnvironment "flushright" }
  1546. proc general {} {
  1547.     catch {prompt "What environment?" ""} environmentName
  1548.     if {$environmentName != "cancel"} {
  1549.         doWrapEnvironment "$environmentName"
  1550. #--------------------------------------------------------------------------
  1551. # Boxes:
  1552. #--------------------------------------------------------------------------
  1553. proc mbox {} {
  1554.     if {[wrapObject "\\mbox{" "}
  1555. "]} then {
  1556.         message "mbox set"
  1557.     } else {
  1558.         message "enter text"
  1559. proc makebox {} {
  1560.     if {[wrapObject "\\makebox\[
  1561. \]{" "}
  1562. "]} then {
  1563.         message "makebox set; enter the width and position"
  1564.     } else {
  1565.         message "enter the width and position of the makebox, then the text"
  1566. proc fbox {} {
  1567.     if {[wrapObject "\\fbox{" "}
  1568. "]} then {
  1569.         message "fbox set"
  1570.     } else {
  1571.         message "enter text"
  1572. proc framebox {} {
  1573.     if {[wrapObject "\\framebox\[
  1574. \]{" "}
  1575. "]} then {
  1576.         message "framebox set; enter the width and position"
  1577.     } else {
  1578.         message "enter the width and position of the framebox, then the text"
  1579. proc newsavebox {} {
  1580.     if {[wrapObject "\\newsavebox{" "}
  1581. "]} then {
  1582.         message "newsavebox defined"
  1583.     } else {
  1584.         message "enter the command name of the sbox or savebox"
  1585. proc sbox {} {
  1586.     if {[wrapObject "\\sbox{
  1587. }{" "}
  1588. "]} then {
  1589.         message "sbox set; enter the command name"
  1590.     } else {
  1591.         message "enter the command name of the sbox, then the text"
  1592. proc savebox {} {
  1593.     if {[wrapObject "\\savebox{
  1594. \]{" "}
  1595. "]} then {
  1596.         message "savebox set; enter the command name"
  1597.     } else {
  1598.         message "enter the command name of the savebox"
  1599. proc usebox {} {
  1600.     if {[wrapObject "\\usebox{" "}
  1601. "]} then {
  1602.         message "usebox declared"
  1603.     } else {
  1604.         message "enter the command name of the sbox or savebox"
  1605. proc raisebox {} {
  1606.     if {[wrapObject "\\raisebox{
  1607. \]{" "}
  1608. "]} then {
  1609.         message "raisebox set; enter the displacement"
  1610.     } else {
  1611.         message "enter the displacement of the raisebox"
  1612. proc parbox {} {
  1613.     if {[wrapObject "\\parbox\[
  1614. \}{" "}
  1615. "]} then {
  1616.         message "parbox set; enter the position and width"
  1617.     } else {
  1618.         message "enter the position \[b|c|t\] and width of the parbox, then the text"
  1619. proc minipage {} {
  1620.     set arg "\[
  1621.     wrapEnvironment "minipage" $arg ""
  1622.     nextTabStop
  1623.     message "enter the position \[b|c|t\] of the minipage, then the width"
  1624. proc rule {} {
  1625.     insertObject "\\rule\[
  1626.     nthTabStop -4
  1627.     message "enter the displacement of the rule, then width and height"
  1628. #--------------------------------------------------------------------------
  1629. # Misc:
  1630. #--------------------------------------------------------------------------
  1631. proc verb {} {
  1632.     if {[wrapObject "\\verb|" "|
  1633. "]} then {
  1634.         message "verbatim text set"
  1635.     } else {
  1636.         message "enter verbatim text"
  1637. proc footnote {} {
  1638.     if {[wrapObject "\\footnote{" "}
  1639. "]} then {
  1640.         message "footnote set"
  1641.     } else {
  1642.         message "enter footnote"
  1643. proc marginalNote {} {
  1644.     if {[wrapObject "\\marginpar{" "}
  1645. "]} then {
  1646.         message "marginal note set"
  1647.     } else {
  1648.         message "enter marginal note"
  1649. proc label {} {
  1650.     if {[wrapObject "\\label{" "}
  1651. "]} then {
  1652.         message "label defined"
  1653.     } else {
  1654.         message "enter label"
  1655. proc ref {} { 
  1656.     TeXRefCompletion "ref"
  1657. proc pageref {} { 
  1658.     TeXRefCompletion "pageref"
  1659. proc cite {} {
  1660.     if {[wrapObject "\\cite{" "}
  1661. "]} then {
  1662.         message "citation made"
  1663.     } else {
  1664.         message "enter citation key"
  1665. proc nocite {} {
  1666.     if {[wrapObject "\\nocite{" "}
  1667. "]} then {
  1668.         message "citation added to the list"
  1669.     } else {
  1670.         message "enter citation key"
  1671. # Insert an \item or a \bibitem, depending on the context.
  1672. proc insertItem {} {
  1673. #     global TeXmodeVars
  1674. #     if {$TeXmodeVars(expertMode) == 0} then {
  1675. #         if {![isInDocument]} then {
  1676. #             if {$TeXmodeVars(searchNoisily)} {beep}
  1677. #             case [askyesno "The cursor is not in the document environment.\
  1678. #                             \rContinue the operation?"] in {
  1679. #                 "yes" {}
  1680. #                 "no" {error "insertItem:  out of context"}
  1681. #             }
  1682. #         }
  1683.     set command [eval getText [searchEnvironment]]
  1684.     set environment [extractCommandArg $command]
  1685.     case $environment in {
  1686.         {itemize enumerate} {
  1687.             set text "\\item  
  1688.         "description" {
  1689.             set text "\\item\[
  1690.         "thebibliography" {
  1691.             set text "\\bibitem{
  1692.         default {
  1693.             beep
  1694.             message "insertItem: cursor in $environment environment"
  1695.             return
  1696.     set pos [getPos]
  1697.     # Indentation should mirror that of an existing \item
  1698.     # (if it exists)
  1699.     insertText [openingCarriageReturn]$text
  1700.     goto $pos
  1701.     nextTabStop
  1702. proc quotes {} {
  1703.     if {[wrapObject "`" "'
  1704. "]} then {
  1705.         message "text quoted"
  1706.     } else {
  1707.         message "enter text"
  1708. proc dblQuotes {} {
  1709.     if {[wrapObject "``" "''
  1710. "]} then {
  1711.         message "text double quoted"
  1712.     } else {
  1713.         message "enter text"
  1714. proc ldots {} {insertObject "\\ldots"}
  1715. proc {en-dash} {} {insertObject "--"}
  1716. proc {em-dash} {} {insertObject "---"}
  1717. proc texLogo {} {insertObject "\\TeX"}
  1718. proc latexLogo {} {insertObject "\\LaTeX"}
  1719. proc latex2eLogo {} {insertObject "\\LaTeXe"}
  1720. proc today {} {insertObject "\\today"}
  1721. proc dag {} {insertObject "\\dag"}
  1722. proc ddag {} {insertObject "\\ddag"}
  1723. proc sectionMark {} {insertObject "\\S"}
  1724. proc paragraphMark {} {insertObject "\\P"}
  1725. proc copyright {} {insertObject "\\copyright"}
  1726. proc pounds {} {insertObject "\\pounds"}
  1727. #############################################################################
  1728. # Math Mode Macros
  1729. #############################################################################
  1730. #--------------------------------------------------------------------------
  1731. # Math Modes:
  1732. #--------------------------------------------------------------------------
  1733. proc texMath {} {
  1734.     checkMathMode "texMath" 0
  1735.     if {[wrapObject "$" "$
  1736. "]} then {
  1737.         message "formula set"
  1738.     } else {
  1739.         message "enter formula"
  1740. proc texDisplaymath {} {
  1741.     checkMathMode "texDisplaymath" 0
  1742.     if {[wrapObject "$$" "$$
  1743. "]} then {
  1744.         message "displayed formula set"
  1745.     } else {
  1746.         message "enter displayed formula"
  1747. proc latexMath {} {
  1748.     checkMathMode "latexMath" 0
  1749.     if {[wrapObject "\\( " " \\)
  1750. "]} then {
  1751.         message "formula set"
  1752.     } else {
  1753.         message "enter formula"
  1754. proc latexDisplaymath {} {
  1755.     checkMathMode "latexDisplaymath" 0
  1756.     if {[wrapObject "\\\[ " " \\\]
  1757. "]} then {
  1758.         message "displayed formula set"
  1759.     } else {
  1760.         message "enter displayed formula"
  1761. #--------------------------------------------------------------------------
  1762. # Math Style:
  1763. #--------------------------------------------------------------------------
  1764. proc mathit {} {
  1765.     checkMathMode "mathit" 1
  1766.     if {[wrapObject "\\mathit{" "}
  1767. "]} then {
  1768.         message "selected text is math italic"
  1769.     } else {
  1770.         message "enter text to be math italic"
  1771. proc mathrm {} {
  1772.     checkMathMode "mathrm" 1
  1773.     if {[wrapObject "\\mathrm{" "}
  1774. "]} then {
  1775.         message "selected text is math roman"
  1776.     } else {
  1777.         message "enter text to be math roman"
  1778. proc mathbf {} {
  1779.     checkMathMode "mathbf" 1
  1780.     if {[wrapObject "\\mathbf{" "}
  1781. "]} then {
  1782.         message "selected text is math bold"
  1783.     } else {
  1784.         message "enter text to be math bold"
  1785. proc mathsf {} {
  1786.     checkMathMode "mathsf" 1
  1787.     if {[wrapObject "\\mathsf{" "}
  1788. "]} then {
  1789.         message "selected text is math sans serif"
  1790.     } else {
  1791.         message "enter text to be math sans serif"
  1792. proc mathtt {} {
  1793.     checkMathMode "mathtt" 1
  1794.     if {[wrapObject "\\mathtt{" "}
  1795. "]} then {
  1796.         message "selected text is math typewriter"
  1797.     } else {
  1798.         message "enter text to be math typewriter"
  1799. proc mathcal {} {
  1800.     checkMathMode "mathcal" 1
  1801.     # Allow upper-case arguments only:
  1802.     if {[isSelection] && ![isUppercase]} then {
  1803.         alertnote "argument to \\mathcal must be uppercase"
  1804.         return
  1805.     if {[wrapObject "\\mathcal{" "}
  1806. "]} then {
  1807.         message "selected text is calligraphic"
  1808.     } else {
  1809.         message "enter text to be calligraphic (UPPERCASE letters only)"
  1810. proc displaystyle {} {
  1811.     checkMathMode "displaystyle" 1
  1812.     if {[wrapObject "{\\displaystyle " "}
  1813. "]} then {
  1814.         message "displaystyle set"
  1815.     } else {
  1816.         message "enter displaystyle text"
  1817. proc textstyle {} {
  1818.     checkMathMode "textstyle" 1
  1819.     if {[wrapObject "{\\textstyle " "}
  1820. "]} then {
  1821.         message "textstyle set"
  1822.     } else {
  1823.         message "enter textstyle text"
  1824. proc scriptstyle {} {
  1825.     checkMathMode "scriptstyle" 1
  1826.     if {[wrapObject "{\\scriptstyle " "}
  1827. "]} then {
  1828.         message "scriptstyle set"
  1829.     } else {
  1830.         message "enter scriptstyle text"
  1831. proc scriptscriptstyle {} {
  1832.     checkMathMode "scriptscriptstyle" 1
  1833.     if {[wrapObject "{\\scriptscriptstyle " "}
  1834. "]} then {
  1835.         message "scriptscriptstyle set"
  1836.     } else {
  1837.         message "enter scriptscriptstyle text"
  1838. #--------------------------------------------------------------------------
  1839. # Math Environments:
  1840. #--------------------------------------------------------------------------
  1841. proc math {} { checkMathMode "math" 0; doWrapEnvironment "math" }
  1842. proc displaymath {} {
  1843.     checkMathMode "displaymath" 0
  1844.     doWrapEnvironment "displaymath"
  1845. proc equation {} {
  1846.     checkMathMode "equation" 0
  1847.     set envName "equation"
  1848.     set body "\t\\label{
  1849.     if {[wrapEnvironment $envName "" $body]} then {
  1850.         set msgText "equation wrapped"
  1851.     } else {
  1852.         set msgText "enter equation"
  1853.     nextTabStop
  1854.     message $msgText
  1855. proc eqnarrayStar {} {
  1856.     global promptNoisily useStatusBar
  1857.     checkMathMode "eqnarrayStar" 0
  1858.     set envName "eqnarray*"
  1859.     if {$promptNoisily && $useStatusBar} {beep}
  1860.     catch {sPrompt "$envName:  how many rows?" 3} numberRows
  1861.     if {$numberRows == "cancel"} then {
  1862.         return
  1863.     } elseif {![isPositiveInteger $numberRows]} then {
  1864.         beep
  1865.         message "invalid input:  unsigned, postive integer required"
  1866.         return
  1867.     set row "\t[buildRow 3]"
  1868.     for {set i 1} {$i < $numberRows} {incr i} {
  1869.         append body $row
  1870.         append body "  \\\\\r"
  1871.     append body $row
  1872.     append body "\r"
  1873.     if {[insertEnvironment $envName "" $body]} then {
  1874.         nextTabStop
  1875.         message "type first item"
  1876. proc eqnarray {} {
  1877.     global promptNoisily useStatusBar
  1878.     checkMathMode "eqnarray" 0
  1879.     set envName "eqnarray"
  1880.     if {$promptNoisily && $useStatusBar} {beep}
  1881.     catch {sPrompt "$envName:  how many rows?" 3} numberRows
  1882.     if {$numberRows == "cancel"} then {
  1883.         return
  1884.     } elseif {![isPositiveInteger $numberRows]} then {
  1885.         beep
  1886.         message "invalid input:  unsigned, postive integer required"
  1887.         return
  1888.     set row "\t[buildRow 3]\r\t\\label{
  1889.     for {set i 1} {$i < $numberRows} {incr i} {
  1890.         append body $row
  1891.         append body "  \\\\\r"
  1892.     append body $row
  1893.     append body "\r"
  1894.     if {[insertEnvironment $envName "" $body]} then {
  1895.         nextTabStop
  1896.         message "type first item"
  1897. proc myArray {} {
  1898.     global promptNoisily useStatusBar
  1899.     checkMathMode "myArray" 1
  1900.     set envName "array"
  1901.     if {$promptNoisily && $useStatusBar} {beep}
  1902.     catch {sPrompt "$envName:  how many rows?" 3} numberRows
  1903.     if {$numberRows == "cancel"} then {
  1904.         return
  1905.     } elseif {![isPositiveInteger $numberRows]} then {
  1906.         beep
  1907.         message "invalid input:  unsigned, postive integer required"
  1908.         return
  1909.     if {$promptNoisily && $useStatusBar} {beep}
  1910.     catch {sPrompt "$envName:  how many columns?" 3} numberCols
  1911.     if {$numberCols == "cancel"} then {
  1912.         return
  1913.     } elseif {![isPositiveInteger $numberCols]} then {
  1914.         beep
  1915.         message "invalid input:  unsigned, postive integer required"
  1916.         return
  1917.     set arg "{"
  1918.     for {set j 1} {$j <= $numberCols} {incr j} {
  1919.         append arg "c"
  1920.     append arg "}"
  1921.     set row "\t[buildRow $numberCols]"
  1922.     for {set i 1} {$i < $numberRows} {incr i} {
  1923.         append body $row
  1924.         append body "  \\\\\r"
  1925.     append body $row
  1926.     append body "\r"
  1927.     if {[insertEnvironment $envName $arg $body]} then {
  1928.         set searchResult [search -s -n -f 1 -m 0 -i 1 -r 1 {c+} [getPos]]
  1929.         select [lindex $searchResult 0] [lindex $searchResult 1]
  1930.         message "Modify this argument?"
  1931. #--------------------------------------------------------------------------
  1932. # Formulas:
  1933. #--------------------------------------------------------------------------
  1934. proc subscript {} {
  1935.     checkMathMode "subscript" 1
  1936.     if {[wrapObject "_{" "}
  1937. "]} then {
  1938.         message "subscript set"
  1939.     } else {
  1940.         message "enter subscript"
  1941. proc superscript {} {
  1942.     checkMathMode "superscript" 1
  1943.     if {[wrapObject "^{" "}
  1944. "]} then {
  1945.         message "superscript set"
  1946.     } else {
  1947.         message "enter superscript"
  1948. proc fraction {} {
  1949.     checkMathMode "fraction" 1
  1950.     set currentPos [getPos]
  1951.     if {[isSelection]} then {
  1952.         set selection [getSelect]
  1953.         set args [split $selection /]
  1954.         set len [llength $args]
  1955.         deleteText $currentPos [selEnd]
  1956.         if {$len == 1} then {
  1957.             insertObject "\\frac{$selection}{
  1958.             goto $currentPos
  1959.             nextTabStop
  1960.             message "enter denominator"
  1961.         } else {
  1962.             set firstArg [lindex $args 0]
  1963.             set restArgs [lrange $args 1 [expr $len-1]]
  1964.             insertObject "\\frac{$firstArg}{[join $restArgs /]}"
  1965.             if {$len > 2} {message "beware of multiple /"}
  1966.     } else {
  1967.         insertObject "\\frac{
  1968.         goto $currentPos
  1969.         nextTabStop
  1970.         message "enter numerator"
  1971. proc squareRoot {} {
  1972.     checkMathMode "squareRoot" 1
  1973.     if {[wrapObject "\\sqrt{" "}
  1974. "]} then {
  1975.         message "square root set"
  1976.     } else {
  1977.         message "enter formula"
  1978. proc nthRoot {} {
  1979.     checkMathMode "nthRoot" 1
  1980.     if {[wrapObject "\\sqrt\[
  1981. \]{" "}
  1982. "]} then {
  1983.         message "enter root"
  1984.     } else {
  1985.         message "enter root, then formula"
  1986. proc oneParameter {} {
  1987.     checkMathMode "oneParameter" 1
  1988.     if {[wrapObject "\\
  1989. {" "}
  1990. "]} then {
  1991.         message "enter command name"
  1992.     } else {
  1993.         message "enter command name, press <Tab>, enter argument"
  1994. proc twoParameters {} {
  1995.     checkMathMode "twoParameters" 1
  1996.     if {[wrapObject "\\
  1997. {" "}{
  1998. "]} then {
  1999.         message "enter command name"
  2000.     } else {
  2001.         message "enter command name, press <Tab>, enter argument, etc."
  2002. #--------------------------------------------------------------------------
  2003. # Greek:
  2004. #--------------------------------------------------------------------------
  2005. proc alpha {} {checkMathMode "alpha" 1; insertObject "\\alpha"}
  2006. proc beta {} {checkMathMode "beta" 1; insertObject "\\beta"}
  2007. proc gamma {} {checkMathMode "gamma" 1; insertObject "\\gamma"}
  2008. proc delta {} {checkMathMode "delta" 1; insertObject "\\delta"}
  2009. proc epsilon {} {checkMathMode "epsilon" 1; insertObject "\\epsilon"}
  2010. proc zeta {} {checkMathMode "zeta" 1; insertObject "\\zeta"}
  2011. proc eta {} {checkMathMode "eta" 1; insertObject "\\eta"}
  2012. proc theta {} {checkMathMode "theta" 1; insertObject "\\theta"}
  2013. proc iota {} {checkMathMode "iota" 1; insertObject "\\iota"}
  2014. proc kappa {} {checkMathMode "kappa" 1; insertObject "\\kappa"}
  2015. proc lambda {} {checkMathMode "lambda" 1; insertObject "\\lambda"}
  2016. proc mu {} {checkMathMode "mu" 1; insertObject "\\mu"}
  2017. proc nu {} {checkMathMode "nu" 1; insertObject "\\nu"}
  2018. proc xi {} {checkMathMode "xi" 1; insertObject "\\xi"}
  2019. proc omicron {} {checkMathMode "omicron" 1; insertObject "o"}
  2020. proc pi {} {checkMathMode "pi" 1; insertObject "\\pi"}
  2021. proc rho {} {checkMathMode "rho" 1; insertObject "\\rho"}
  2022. proc sigma {} {checkMathMode "sigma" 1; insertObject "\\sigma"}
  2023. proc tau {} {checkMathMode "tau" 1; insertObject "\\tau"}
  2024. proc upsilon {} {checkMathMode "upsilon" 1; insertObject "\\upsilon"}
  2025. proc phi {} {checkMathMode "phi" 1; insertObject "\\phi"}
  2026. proc chi {} {checkMathMode "chi" 1; insertObject "\\chi"}
  2027. proc psi {} {checkMathMode "psi" 1; insertObject "\\psi"}
  2028. proc omega {} {checkMathMode "omega" 1; insertObject "\\omega"}
  2029. proc Gamma {} {checkMathMode "Gamma" 1; insertObject "\\Gamma"}
  2030. proc Delta {} {checkMathMode "Delta" 1; insertObject "\\Delta"}
  2031. proc Theta {} {checkMathMode "Theta" 1; insertObject "\\Theta"}
  2032. proc Lambda {} {checkMathMode "Lambda" 1; insertObject "\\Lambda"}
  2033. proc Xi {} {checkMathMode "Xi" 1; insertObject "\\Xi"}
  2034. proc Pi {} {checkMathMode "Pi" 1; insertObject "\\Pi"}
  2035. proc Sigma {} {checkMathMode "Sigma" 1; insertObject "\\Sigma"}
  2036. proc Upsilon {} {checkMathMode "Upsilon" 1; insertObject "\\Upsilon"}
  2037. proc Phi {} {checkMathMode "Phi" 1; insertObject "\\Phi"}
  2038. proc Psi {} {checkMathMode "Psi" 1; insertObject "\\Psi"}
  2039. proc Omega {} {checkMathMode "Omega" 1; insertObject "\\Omega"}
  2040. proc varepsilon {} {checkMathMode "varepsilon" 1; insertObject "\\varepsilon"}
  2041. proc vartheta {} {checkMathMode "vartheta" 1; insertObject "\\vartheta"}
  2042. proc varpi {} {checkMathMode "varpi" 1; insertObject "\\varpi"}
  2043. proc varrho {} {checkMathMode "varrho" 1; insertObject "\\varrho"}
  2044. proc varsigma {} {checkMathMode "varsigma" 1; insertObject "\\varsigma"}
  2045. proc varphi {} {checkMathMode "varphi" 1; insertObject "\\varphi"}
  2046. #--------------------------------------------------------------------------
  2047. # Binary Ops:
  2048. #--------------------------------------------------------------------------
  2049. proc pm {} {checkMathMode "pm" 1; insertObject "\\pm"}
  2050. proc mp {} {checkMathMode "mp" 1; insertObject "\\mp"}
  2051. proc times {} {checkMathMode "times" 1; insertObject "\\times"}
  2052. proc div {} {checkMathMode "div" 1; insertObject "\\div"}
  2053. proc ast {} {checkMathMode "ast" 1; insertObject "\\ast"}
  2054. proc star {} {checkMathMode "star" 1; insertObject "\\star"}
  2055. proc circ {} {checkMathMode "circ" 1; insertObject "\\circ"}
  2056. proc bullet {} {checkMathMode "bullet" 1; insertObject "\\bullet"}
  2057. proc cdot {} {checkMathMode "cdot" 1; insertObject "\\cdot"}
  2058. proc cap {} {checkMathMode "cap" 1; insertObject "\\cap"}
  2059. proc cup {} {checkMathMode "cup" 1; insertObject "\\cup"}
  2060. proc uplus {} {checkMathMode "uplus" 1; insertObject "\\uplus"}
  2061. proc sqcap {} {checkMathMode "sqcap" 1; insertObject "\\sqcap"}
  2062. proc sqcup {} {checkMathMode "sqcup" 1; insertObject "\\sqcup"}
  2063. proc vee {} {checkMathMode "vee" 1; insertObject "\\vee"}
  2064. proc wedge {} {checkMathMode "wedge" 1; insertObject "\\wedge"}
  2065. proc setminus {} {checkMathMode "setminus" 1; insertObject "\\setminus"}
  2066. proc wr {} {checkMathMode "wr" 1; insertObject "\\wr"}
  2067. proc diamond {} {checkMathMode "diamond" 1; insertObject "\\diamond"}
  2068. proc bigtriangleup {} {
  2069.     checkMathMode "bigtriangleup" 1; insertObject "\\bigtriangleup"
  2070. proc bigtriangledown {} {
  2071.     checkMathMode "bigtriangledown" 1; insertObject "\\bigtriangledown"
  2072. proc triangleleft {} {
  2073.     checkMathMode "triangleleft" 1; insertObject "\\triangleleft"
  2074. proc triangleright {} {
  2075.     checkMathMode "triangleright" 1; insertObject "\\triangleright"
  2076. proc lhd {} {
  2077.     if {[isSymbolPackageLoaded]} then {
  2078.         checkMathMode "lhd" 1; insertObject "\\lhd"
  2079. proc rhd {} {
  2080.     if {[isSymbolPackageLoaded]} then {
  2081.         checkMathMode "rhd" 1; insertObject "\\rhd"
  2082. proc unlhd {} {
  2083.     if {[isSymbolPackageLoaded]} then {
  2084.         checkMathMode "unlhd" 1; insertObject "\\unlhd"
  2085. proc unrhd {} {
  2086.     if {[isSymbolPackageLoaded]} then {
  2087.         checkMathMode "unrhd" 1; insertObject "\\unrhd"
  2088. proc oplus {} {checkMathMode "oplus" 1; insertObject "\\oplus"}
  2089. proc ominus {} {checkMathMode "ominus" 1; insertObject "\\ominus"}
  2090. proc otimes {} {checkMathMode "otimes" 1; insertObject "\\otimes"}
  2091. proc oslash {} {checkMathMode "oslash" 1; insertObject "\\oslash"}
  2092. proc odot {} {checkMathMode "odot" 1; insertObject "\\odot"}
  2093. proc bigcirc {} {checkMathMode "bigcirc" 1; insertObject "\\bigcirc"}
  2094. proc dagger {} {checkMathMode "dagger" 1; insertObject "\\dagger"}
  2095. proc ddagger {} {checkMathMode "ddagger" 1; insertObject "\\ddagger"}
  2096. proc amalg {} {checkMathMode "amalg" 1; insertObject "\\amalg"}
  2097. #--------------------------------------------------------------------------
  2098. # Relations:
  2099. #--------------------------------------------------------------------------
  2100. proc leq {} {checkMathMode "leq" 1; insertObject "\\leq"}
  2101. proc prec {} {checkMathMode "prec" 1; insertObject "\\prec"}
  2102. proc preceq {} {checkMathMode "preceq" 1; insertObject "\\preceq"}
  2103. proc myLl {} {checkMathMode "myLl" 1; insertObject "\\ll"}
  2104. proc subset {} {checkMathMode "subset" 1; insertObject "\\subset"}
  2105. proc subseteq {} {checkMathMode "subseteq" 1; insertObject "\\subseteq"}
  2106. proc sqsubset {} {
  2107.     if {[isSymbolPackageLoaded]} then {
  2108.         checkMathMode "sqsubset" 1; insertObject "\\sqsubset"
  2109. proc sqsubseteq {} {checkMathMode "sqsubseteq" 1; insertObject "\\sqsubseteq"}
  2110. proc in {} {checkMathMode "in" 1; insertObject "\\in"}
  2111. proc vdash {} {checkMathMode "vdash" 1; insertObject "\\vdash"}
  2112. proc geq {} {checkMathMode "geq" 1; insertObject "\\geq"}
  2113. proc succ {} {checkMathMode "succ" 1; insertObject "\\succ"}
  2114. proc succeq {} {checkMathMode "succeq" 1; insertObject "\\succeq"}
  2115. proc gg {} {checkMathMode "gg" 1; insertObject "\\gg"}
  2116. proc supset {} {checkMathMode "supset" 1; insertObject "\\supset"}
  2117. proc supseteq {} {checkMathMode "supseteq" 1; insertObject "\\supseteq"}
  2118. proc sqsupset {} {
  2119.     if {[isSymbolPackageLoaded]} then {
  2120.         checkMathMode "sqsupset" 1; insertObject "\\sqsupset"
  2121. proc sqsupseteq {} {checkMathMode "sqsupseteq" 1; insertObject "\\sqsupseteq"}
  2122. proc ni {} {checkMathMode "ni" 1; insertObject "\\ni"}
  2123. proc dashv {} {checkMathMode "dashv" 1; insertObject "\\dashv"}
  2124. proc equiv {} {checkMathMode "equiv" 1; insertObject "\\equiv"}
  2125. proc sim {} {checkMathMode "sim" 1; insertObject "\\sim"}
  2126. proc simeq {} {checkMathMode "simeq" 1; insertObject "\\simeq"}
  2127. proc asymp {} {checkMathMode "asymp" 1; insertObject "\\asymp"}
  2128. proc approx {} {checkMathMode "approx" 1; insertObject "\\approx"}
  2129. proc cong {} {checkMathMode "cong" 1; insertObject "\\cong"}
  2130. proc neq {} {checkMathMode "neq" 1; insertObject "\\neq"}
  2131. proc doteq {} {checkMathMode "doteq" 1; insertObject "\\doteq"}
  2132. proc propto {} {checkMathMode "propto" 1; insertObject "\\propto"}
  2133. proc models {} {checkMathMode "models" 1; insertObject "\\models"}
  2134. proc perp {} {checkMathMode "perp" 1; insertObject "\\perp"}
  2135. proc mid {} {checkMathMode "mid" 1; insertObject "\\mid"}
  2136. proc parallel {} {checkMathMode "parallel" 1; insertObject "\\parallel"}
  2137. proc bowtie {} {checkMathMode "bowtie" 1; insertObject "\\bowtie"}
  2138. proc myJoin {} {
  2139.     if {[isSymbolPackageLoaded]} then {
  2140.         checkMathMode "myJoin" 1; insertObject "\\join"
  2141. proc smile {} {checkMathMode "smile" 1; insertObject "\\smile"}
  2142. proc frown {} {checkMathMode "frown" 1; insertObject "\\frown"}
  2143. #--------------------------------------------------------------------------
  2144. # Arrows:
  2145. #--------------------------------------------------------------------------
  2146. proc leftarrow {} {checkMathMode "leftarrow" 1; insertObject "\\leftarrow"}
  2147. proc Leftarrow {} {checkMathMode "Leftarrow" 1; insertObject "\\Leftarrow"}
  2148. proc rightarrow {} {checkMathMode "rightarrow" 1; insertObject "\\rightarrow"}
  2149. proc Rightarrow {} {checkMathMode "Rightarrow" 1; insertObject "\\Rightarrow"}
  2150. proc leftrightarrow {} {
  2151.     checkMathMode "leftrightarrow" 1; insertObject "\\leftrightarrow"
  2152. proc Leftrightarrow {} {
  2153.     checkMathMode "Leftrightarrow" 1; insertObject "\\Leftrightarrow"
  2154. proc mapsto {} {checkMathMode "mapsto" 1; insertObject "\\mapsto"}
  2155. proc hookleftarrow {} {
  2156.     checkMathMode "hookleftarrow" 1; insertObject "\\hookleftarrow"
  2157. proc leftharpoonup {} {
  2158.     checkMathMode "leftharpoonup" 1; insertObject "\\leftharpoonup"
  2159. proc leftharpoondown {} {
  2160.     checkMathMode "leftharpoondown" 1; insertObject "\\leftharpoondown"
  2161. proc rightleftharpoons {} {
  2162.     checkMathMode "rightleftharpoons" 1; insertObject "\\rightleftharpoons"
  2163. proc longleftarrow {} {
  2164.     checkMathMode "longleftarrow" 1; insertObject "\\longleftarrow"
  2165. proc Longleftarrow {} {
  2166.     checkMathMode "Longleftarrow" 1; insertObject "\\Longleftarrow"
  2167. proc longrightarrow {} {
  2168.     checkMathMode "longrightarrow" 1; insertObject "\\longrightarrow"
  2169. proc Longrightarrow {} {
  2170.     checkMathMode "Longrightarrow" 1; insertObject "\\Longrightarrow"
  2171. proc longleftrightarrow {} {
  2172.     checkMathMode "longleftrightarrow" 1; insertObject "\\longleftrightarrow"
  2173. proc Longleftrightarrow {} {
  2174.     checkMathMode "Longleftrightarrow" 1; insertObject "\\Longleftrightarrow"
  2175. proc longmapsto {} {checkMathMode "longmapsto" 1; insertObject "\\longmapsto"}
  2176. proc hookrightarrow {} {
  2177.     checkMathMode "hookrightarrow" 1; insertObject "\\hookrightarrow"
  2178. proc rightharpoonup {} {
  2179.     checkMathMode "rightharpoonup" 1; insertObject "\\rightharpoonup"
  2180. proc rightharpoondown {} {
  2181.     checkMathMode "rightharpoondown" 1; insertObject "\\rightharpoondown"
  2182. proc leadsto {} {
  2183.     if {[isSymbolPackageLoaded]} then {
  2184.         checkMathMode "leadsto" 1; insertObject "\\leadsto"
  2185. proc uparrow {} {checkMathMode "uparrow" 1; insertObject "\\uparrow"}
  2186. proc Uparrow {} {checkMathMode "Uparrow" 1; insertObject "\\Uparrow"}
  2187. proc downarrow {} {checkMathMode "downarrow" 1; insertObject "\\downarrow"}
  2188. proc Downarrow {} {checkMathMode "Downarrow" 1; insertObject "\\Downarrow"}
  2189. proc updownarrow {} {checkMathMode "updownarrow" 1; insertObject "\\updownarrow"}
  2190. proc Updownarrow {} {checkMathMode "Updownarrow" 1; insertObject "\\Updownarrow"}
  2191. proc nearrow {} {checkMathMode "nearrow" 1; insertObject "\\nearrow"}
  2192. proc searrow {} {checkMathMode "searrow" 1; insertObject "\\searrow"}
  2193. proc swarrow {} {checkMathMode "swarrow" 1; insertObject "\\swarrow"}
  2194. proc nwarrow {} {checkMathMode "nwarrow" 1; insertObject "\\nwarrow"}
  2195. #--------------------------------------------------------------------------
  2196. # Dots:
  2197. #--------------------------------------------------------------------------
  2198. proc cdots {} {checkMathMode "cdots" 1; insertObject "\\cdots"}
  2199. proc vdots {} {checkMathMode "vdots" 1; insertObject "\\vdots"}
  2200. proc ddots {} {checkMathMode "ddots" 1; insertObject "\\ddots"}
  2201. #--------------------------------------------------------------------------
  2202. # Symbols:
  2203. #--------------------------------------------------------------------------
  2204. proc aleph {} {checkMathMode "aleph" 1; insertObject "\\aleph"}
  2205. proc hbar {} {checkMathMode "hbar" 1; insertObject "\\hbar"}
  2206. proc imath {} {checkMathMode "imath" 1; insertObject "\\imath"}
  2207. proc jmath {} {checkMathMode "jmath" 1; insertObject "\\jmath"}
  2208. proc ell {} {checkMathMode "ell" 1; insertObject "\\ell"}
  2209. proc wp {} {checkMathMode "wp" 1; insertObject "\\wp"}
  2210. proc Re {} {checkMathMode "Re" 1; insertObject "\\Re"}
  2211. proc Im {} {checkMathMode "Im" 1; insertObject "\\Im"}
  2212. proc mho {} {
  2213.     if {[isSymbolPackageLoaded]} then {
  2214.         checkMathMode "mho" 1; insertObject "\\mho"
  2215. proc prime {} {checkMathMode "prime" 1; insertObject "\\prime"}
  2216. proc emptyset {} {checkMathMode "emptyset" 1; insertObject "\\emptyset"}
  2217. proc nabla {} {checkMathMode "nabla" 1; insertObject "\\nabla"}
  2218. proc surd {} {checkMathMode "surd" 1; insertObject "\\surd"}
  2219. proc top {} {checkMathMode "top" 1; insertObject "\\top"}
  2220. proc bot {} {checkMathMode "bot" 1; insertObject "\\bot"}
  2221. # proc | {} {checkMathMode "|" 1; insertObject "\\|"}
  2222. proc angle {} {checkMathMode "angle" 1; insertObject "\\angle"}
  2223. proc forall {} {checkMathMode "forall" 1; insertObject "\\forall"}
  2224. proc exists {} {checkMathMode "exists" 1; insertObject "\\exists"}
  2225. proc neg {} {checkMathMode "neg" 1; insertObject "\\neg"}
  2226. proc flat {} {checkMathMode "flat" 1; insertObject "\\flat"}
  2227. proc natural {} {checkMathMode "natural" 1; insertObject "\\natural"}
  2228. proc sharp {} {checkMathMode "sharp" 1; insertObject "\\sharp"}
  2229. proc backslash {} {checkMathMode "backslash" 1; insertObject "\\backslash"}
  2230. proc partial {} {checkMathMode "partial" 1; insertObject "\\partial"}
  2231. proc infty {} {checkMathMode "infty" 1; insertObject "\\infty"}
  2232. proc Box {} {
  2233.     if {[isSymbolPackageLoaded]} then {
  2234.         checkMathMode "Box" 1; insertObject "\\Box"
  2235. proc Diamond {} {
  2236.     if {[isSymbolPackageLoaded]} then {
  2237.         checkMathMode "Diamond" 1; insertObject "\\Diamond"
  2238. proc triangle {} {checkMathMode "triangle" 1; insertObject "\\triangle"}
  2239. proc clubsuit {} {checkMathMode "clubsuit" 1; insertObject "\\clubsuit"}
  2240. proc diamondsuit {} {checkMathMode "diamondsuit" 1; insertObject "\\diamondsuit"}
  2241. proc heartsuit {} {checkMathMode "heartsuit" 1; insertObject "\\heartsuit"}
  2242. proc spadesuit {} {checkMathMode "spadesuit" 1; insertObject "\\spadesuit"}
  2243. #--------------------------------------------------------------------------
  2244. # Functions:
  2245. #--------------------------------------------------------------------------
  2246. proc arccos {} {checkMathMode "arccos" 1; insertObject "\\arccos"}
  2247. proc arcsin {} {checkMathMode "arcsin" 1; insertObject "\\arcsin"}
  2248. proc arctan {} {checkMathMode "arctan" 1; insertObject "\\arctan"}
  2249. proc arg {} {checkMathMode "arg" 1; insertObject "\\arg"}
  2250. proc cos {} {checkMathMode "cos" 1; insertObject "\\cos"}
  2251. proc cosh {} {checkMathMode "cosh" 1; insertObject "\\cosh"}
  2252. proc cot {} {checkMathMode "cot" 1; insertObject "\\cot"}
  2253. proc coth {} {checkMathMode "coth" 1; insertObject "\\coth"}
  2254. proc csc {} {checkMathMode "csc" 1; insertObject "\\csc"}
  2255. proc deg {} {checkMathMode "deg" 1; insertObject "\\deg"}
  2256. proc det {} {checkMathMode "det" 1; insertObject "\\det"}
  2257. proc dim {} {checkMathMode "dim" 1; insertObject "\\dim"}
  2258. proc exp {} {checkMathMode "exp" 1; insertObject "\\exp"}
  2259. proc gcd {} {checkMathMode "gcd" 1; insertObject "\\gcd"}
  2260. proc hom {} {checkMathMode "hom" 1; insertObject "\\hom"}
  2261. # proc inf {} {checkMathMode "inf" 1; insertObject "\\inf"}
  2262. proc inf {} {
  2263.     checkMathMode "inf" 1
  2264.     if {[wrapObject "\\inf_{" "}
  2265. "]} then {
  2266.         message "limit set"
  2267.     } else {
  2268.         message "enter limit"
  2269. proc ker {} {checkMathMode "ker" 1; insertObject "\\ker"}
  2270. proc lg {} {checkMathMode "lg" 1; insertObject "\\lg"}
  2271. # proc lim {} {checkMathMode "lim" 1; insertObject "\\lim"}
  2272. proc lim {} {
  2273.     checkMathMode "lim" 1
  2274.     if {[wrapObject "\\lim_{" "}
  2275. "]} then {
  2276.         message "limit set"
  2277.     } else {
  2278.         message "enter limit"
  2279. # proc liminf {} {checkMathMode "liminf" 1; insertObject "\\liminf"}
  2280. proc liminf {} {
  2281.     checkMathMode "liminf" 1
  2282.     if {[wrapObject "\\liminf_{" "}
  2283. "]} then {
  2284.         message "limit set"
  2285.     } else {
  2286.         message "enter limit"
  2287. # proc limsup {} {checkMathMode "limsup" 1; insertObject "\\limsup"}
  2288. proc limsup {} {
  2289.     checkMathMode "limsup" 1
  2290.     if {[wrapObject "\\limsup_{" "}
  2291. "]} then {
  2292.         message "limit set"
  2293.     } else {
  2294.         message "enter limit"
  2295. proc ln {} {checkMathMode "ln" 1; insertObject "\\ln"}
  2296. proc log {} {checkMathMode "log" 1; insertObject "\\log"}
  2297. # proc max {} {checkMathMode "max" 1; insertObject "\\max"}
  2298. proc max {} {
  2299.     checkMathMode "max" 1
  2300.     if {[wrapObject "\\max_{" "}
  2301. "]} then {
  2302.         message "limit set"
  2303.     } else {
  2304.         message "enter limit"
  2305. # proc min {} {checkMathMode "min" 1; insertObject "\\min"}
  2306. proc min {} {
  2307.     checkMathMode "min" 1
  2308.     if {[wrapObject "\\min_{" "}
  2309. "]} then {
  2310.         message "limit set"
  2311.     } else {
  2312.         message "enter limit"
  2313. proc Pr {} {checkMathMode "Pr" 1; insertObject "\\Pr"}
  2314. proc sec {} {checkMathMode "sec" 1; insertObject "\\sec"}
  2315. proc sin {} {checkMathMode "sin" 1; insertObject "\\sin"}
  2316. proc sinh {} {checkMathMode "sinh" 1; insertObject "\\sinh"}
  2317. # proc sup {} {checkMathMode "sup" 1; insertObject "\\sup"}
  2318. proc sup {} {
  2319.     checkMathMode "sup" 1
  2320.     if {[wrapObject "\\sup_{" "}
  2321. "]} then {
  2322.         message "limit set"
  2323.     } else {
  2324.         message "enter limit"
  2325. proc tan {} {checkMathMode "tan" 1; insertObject "\\tan"}
  2326. proc tanh {} {checkMathMode "tanh" 1; insertObject "\\tanh"}
  2327. proc bmod {} {checkMathMode "bmod" 1; insertObject "\\bmod"}
  2328. proc pmod {} {
  2329.     checkMathMode "pmod" 1
  2330.     if {[wrapObject "\\pmod{" "}
  2331. "]} then {
  2332.         message "parenthesized mod set"
  2333.     } else {
  2334.         message "enter formula"
  2335. #--------------------------------------------------------------------------
  2336. # Large Ops:
  2337. #--------------------------------------------------------------------------
  2338. proc insertLargeOp {commandName} {
  2339.     checkMathMode "$commandName" 1
  2340.     set currentPos [getPos]
  2341.     insertObject "\\$commandName\_{
  2342.     goto $currentPos
  2343.     nextTabStop
  2344. proc sum {} {insertLargeOp "sum"}
  2345. proc prod {} {insertLargeOp "prod"}
  2346. proc coprod {} {insertLargeOp "coprod"}
  2347. proc int {} {insertLargeOp "int"}
  2348. proc oint {} {insertLargeOp "oint"}
  2349. proc bigcap {} {insertLargeOp "bigcap"}
  2350. proc bigcup {} {insertLargeOp "bigcup"}
  2351. proc bigsqcup {} {insertLargeOp "bigsqcup"}
  2352. proc bigvee {} {insertLargeOp "bigvee"}
  2353. proc bigwedge {} {insertLargeOp "bigwedge"}
  2354. proc bigodot {} {insertLargeOp "bigodot"}
  2355. proc bigotimes {} {insertLargeOp "bigotimes"}
  2356. proc bigoplus {} {insertLargeOp "bigoplus"}
  2357. proc biguplus {} {insertLargeOp "biguplus"}
  2358. #--------------------------------------------------------------------------
  2359. # Delimiters:
  2360. #--------------------------------------------------------------------------
  2361. proc delimitObject {leftDelim rightDelim} {
  2362.     if {[wrapObject $leftDelim $rightDelim]} then {
  2363.         message "formula delimited"
  2364.     } else {
  2365.         message "enter formula"
  2366. proc parentheses {} { checkMathMode "parentheses" 1; delimitObject "(" ")
  2367. proc brackets {} { checkMathMode "brackets" 1; delimitObject "\[" "\]
  2368. proc braces {} { checkMathMode "braces" 1; delimitObject "\\\{" "\\\}
  2369. proc absoluteValue {} { checkMathMode "absoluteValue" 1; delimitObject "|" "|
  2370. proc getDelims {} {
  2371.     catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" \
  2372.                   "brackets" "braces" "angle brackets" "vertical bars" \
  2373.                   "double bars" "ceiling" "floor"} delimType
  2374.     if {$delimType != "cancel"} then {
  2375.         case $delimType in {
  2376.             "parentheses" {
  2377.                 set leftDelim "("
  2378.                 set rightDelim ")"
  2379.             "brackets" {
  2380.                 set leftDelim "\["
  2381.                 set rightDelim "\]"
  2382.             "braces" {
  2383.                 set leftDelim "\\\{"
  2384.                 set rightDelim "\\\}"
  2385.             "{vertical bars}" {
  2386.                 set leftDelim "|"
  2387.                 set rightDelim "|"
  2388.             "{double bars}" {
  2389.                 set leftDelim "\\|"
  2390.                 set rightDelim "\\|"
  2391.             "{angle brackets}" {
  2392.                 set leftDelim "\\langle"
  2393.                 set rightDelim "\\rangle"
  2394.             "ceiling" {
  2395.                 set leftDelim "\\lceil"
  2396.                 set rightDelim "\\rceil"
  2397.             "floor" {
  2398.                 set leftDelim "\\lfloor"
  2399.                 set rightDelim "\\rfloor"
  2400.             default {
  2401.                 alertnote "\"$delimType\" not recognized"
  2402.                 return ""
  2403.         return [list $leftDelim $rightDelim]
  2404.     } else {return ""}
  2405. proc otherDelims {} {
  2406.     checkMathMode "otherDelims" 1
  2407.     set delims [getDelims]
  2408.     if {$delims != ""} then {
  2409.         set leftDelim [lindex $delims 0]
  2410.         set rightDelim [lindex $delims 1]
  2411.         delimitObject "$leftDelim" "$rightDelim
  2412. proc {half-openInterval} {} {
  2413.     checkMathMode "half-openInterval" 1; delimitObject "(" "\]
  2414. proc {half-closedInterval} {} {
  2415.     checkMathMode "half-closedInterval" 1; delimitObject "\[" ")
  2416. proc insertBigDelims {leftDelim rightDelim isMultiline} {
  2417.     checkMathMode "insertBigDelims" 1
  2418.     if {$isMultiline} then {
  2419.         alertnote "Multi-line delimiters not yet implemented."
  2420.     } else {
  2421.         if {[wrapObject $leftDelim $rightDelim]} then {
  2422.             message "formula delimited"
  2423.         } else {
  2424.             message "enter formula"
  2425. proc bigParentheses {} {
  2426.     checkMathMode "bigParentheses" 1; insertBigDelims "\\left(" "\\right)
  2427. proc bigBrackets {} {
  2428.     checkMathMode "bigBrackets" 1; insertBigDelims "\\left\[" "\\right\]
  2429. proc bigBraces {} {
  2430.     checkMathMode "bigBraces" 1; insertBigDelims "\\left\\\{" "\\right\\\}
  2431. proc bigAbsoluteValue {} {
  2432.     checkMathMode "bigAbsoluteValue" 1; insertBigDelims "\\left|" "\\right|
  2433. proc otherBigDelims {} {
  2434.     checkMathMode "otherBigDelims" 1
  2435.     set delims [getDelims]
  2436.     if {$delims != ""} then {
  2437.         append leftDelim "\\left" [lindex $delims 0]
  2438.         append rightDelim "\\right" [lindex $delims 1]
  2439.         insertBigDelims "$leftDelim" "$rightDelim
  2440. proc bigLeftBrace {} { checkMathMode "bigLeftBrace" 1; insertBigDelims "\\left\\\{" "\\right.
  2441. " 0 }
  2442. proc otherMixedBigDelims {} {
  2443.     checkMathMode "otherMixedBigDelims" 1
  2444.     catch {prompt "Choose LEFT delimiter:" "parenthesis" "" "parenthesis" \
  2445.                   "bracket" "brace" "vertical bar" "double bar" \
  2446.                   "angle bracket" "ceiling" "floor" "slash" "backslash" \
  2447.                   "none"} delimType
  2448.     if {$delimType != "cancel"} then {
  2449.         case $delimType in {
  2450.             "parenthesis" {set leftDelim "("}
  2451.             "bracket" {set leftDelim "\["}
  2452.             "brace" {set leftDelim "\\\{"}
  2453.             "{vertical bar}" {set leftDelim "|"}
  2454.             "{double bar}" {set leftDelim "\\|"}
  2455.             "{angle bracket}" {set leftDelim "\\langle"}
  2456.             "ceiling" {set leftDelim "\\lceil"}
  2457.             "floor" {set leftDelim "\\lfloor"}
  2458.             "slash" {set leftDelim "/"}
  2459.             "backslash" {set leftDelim "\\backslash"}
  2460.             "none" {set leftDelim "."}
  2461.             default {
  2462.                 alertnote "\"$delimType\" not recognized"
  2463.                 return
  2464.         catch {prompt "Choose RIGHT delimiter:" "parenthesis" "" "parenthesis" \
  2465.                       "bracket" "brace" "vertical bar" "double bar" \
  2466.                       "angle bracket" "ceiling" "floor" "slash" "backslash" \
  2467.                       "none"} delimType
  2468.         if {$delimType != "cancel"} then {
  2469.             case $delimType in {
  2470.                 "parenthesis" {set rightDelim ")"}
  2471.                 "bracket" {set rightDelim "\]"}
  2472.                 "brace" {set rightDelim "\\\}"}
  2473.                 "{vertical bar}" {set rightDelim "|"}
  2474.                 "{double bar}" {set rightDelim "\\|"}
  2475.                 "{angle bracket}" {set rightDelim "\\rangle"}
  2476.                 "ceiling" {set rightDelim "\\rceil"}
  2477.                 "floor" {set rightDelim "\\rfloor"}
  2478.                 "slash" {set rightDelim "/"}
  2479.                 "backslash" {set rightDelim "\\backslash"}
  2480.                 "none" {set rightDelim "."}
  2481.                 default {
  2482.                     alertnote "\"$delimType\" not recognized"
  2483.                     return
  2484.                 }
  2485.             insertBigDelims "\\left$leftDelim" "\\right$rightDelim
  2486. #--------------------------------------------------------------------------
  2487. # Accents:
  2488. #--------------------------------------------------------------------------
  2489. proc acute {} {
  2490.     checkMathMode "acute" 1
  2491.     if {[isSelection] > 1} then {
  2492.         alertnote "Warning: only a single character may be accented!"
  2493.     if {[wrapObject "\\acute{" "}
  2494. "]} then {
  2495.         message "accent set"
  2496.     } else {
  2497.         message "enter one character"
  2498. proc bar {} {
  2499.     checkMathMode "bar" 1
  2500.     if {[isSelection] > 1} then {
  2501.         alertnote "Warning: only a single character may be accented!"
  2502.     if {[wrapObject "\\bar{" "}
  2503. "]} then {
  2504.         message "accent set"
  2505.     } else {
  2506.         message "enter one character"
  2507. proc breve {} {
  2508.     checkMathMode "breve" 1
  2509.     if {[isSelection] > 1} then {
  2510.         alertnote "Warning: only a single character may be accented!"
  2511.     if {[wrapObject "\\breve{" "}
  2512. "]} then {
  2513.         message "accent set"
  2514.     } else {
  2515.         message "enter one character"
  2516. proc check {} {
  2517.     checkMathMode "check" 1
  2518.     if {[isSelection] > 1} then {
  2519.         alertnote "Warning: only a single character may be accented!"
  2520.     if {[wrapObject "\\check{" "}
  2521. "]} then {
  2522.         message "accent set"
  2523.     } else {
  2524.         message "enter one character"
  2525. proc dot {} {
  2526.     checkMathMode "dot" 1
  2527.     if {[isSelection] > 1} then {
  2528.         alertnote "Warning: only a single character may be accented!"
  2529.     if {[wrapObject "\\dot{" "}
  2530. "]} then {
  2531.         message "accent set"
  2532.     } else {
  2533.         message "enter one character"
  2534. proc ddot {} {
  2535.     checkMathMode "ddot" 1
  2536.     if {[isSelection] > 1} then {
  2537.         alertnote "Warning: only a single character may be accented!"
  2538.     if {[wrapObject "\\ddot{" "}
  2539. "]} then {
  2540.         message "accent set"
  2541.     } else {
  2542.         message "enter one character"
  2543. proc grave {} {
  2544.     checkMathMode "grave" 1
  2545.     if {[isSelection] > 1} then {
  2546.         alertnote "Warning: only a single character may be accented!"
  2547.     if {[wrapObject "\\grave{" "}
  2548. "]} then {
  2549.         message "accent set"
  2550.     } else {
  2551.         message "enter one character"
  2552. proc hat {} {
  2553.     checkMathMode "hat" 1
  2554.     if {[isSelection] > 1} then {
  2555.         alertnote "Warning: only a single character may be accented!"
  2556.     if {[wrapObject "\\hat{" "}
  2557. "]} then {
  2558.         message "accent set"
  2559.     } else {
  2560.         message "enter one character"
  2561. proc tilde {} {
  2562.     checkMathMode "tilde" 1
  2563.     if {[isSelection] > 1} then {
  2564.         alertnote "Warning: only a single character may be accented!"
  2565.     if {[wrapObject "\\tilde{" "}
  2566. "]} then {
  2567.         message "accent set"
  2568.     } else {
  2569.         message "enter one character"
  2570. proc vec {} {
  2571.     checkMathMode "vec" 1
  2572.     if {[isSelection] > 1} then {
  2573.         alertnote "Warning: only a single character may be accented!"
  2574.     if {[wrapObject "\\vec{" "}
  2575. "]} then {
  2576.         message "accent set"
  2577.     } else {
  2578.         message "enter one character"
  2579. proc widehat {} {
  2580.     checkMathMode "widehat" 1
  2581.     if {[isSelection] > 3} then {
  2582.         alertnote "Warning: only a few characters may be accented!"
  2583.     if {[wrapObject "\\widehat{" "}
  2584. "]} then {
  2585.         message "accent set"
  2586.     } else {
  2587.         message "enter a few characters"
  2588. proc widetilde {} {
  2589.     checkMathMode "widetilde" 1
  2590.     if {[isSelection] > 3} then {
  2591.         alertnote "Warning: only a few characters may be accented!"
  2592.     if {[wrapObject "\\widetilde{" "}
  2593. "]} then {
  2594.         message "accent set"
  2595.     } else {
  2596.         message "enter a few characters"
  2597. proc imath {} {checkMathMode "imath" 1; insertObject "\\imath"}
  2598. proc jmath {} {checkMathMode "jmath" 1; insertObject "\\jmath"}
  2599. #--------------------------------------------------------------------------
  2600. # Grouping:
  2601. #--------------------------------------------------------------------------
  2602. proc underline {} {
  2603.     checkMathMode "underline" 1
  2604.     if {[wrapObject "\\underline{" "}
  2605. "]} then {
  2606.         message "selection underlined"
  2607.     } else {
  2608.         message "enter text"
  2609. proc overline {} {
  2610.     checkMathMode "overline" 1
  2611.     if {[wrapObject "\\overline{" "}
  2612. "]} then {
  2613.         message "selection overlined"
  2614.     } else {
  2615.         message "enter text"
  2616. proc underbrace {} {
  2617.     checkMathMode "underbrace" 1
  2618.     if {[wrapObject "\\underbrace{" "}
  2619. "]} then {
  2620.         message "selection underbraced"
  2621.     } else {
  2622.         message "enter text"
  2623. proc overbrace {} {
  2624.     checkMathMode "overbrace" 1
  2625.     if {[wrapObject "\\overbrace{" "}
  2626. "]} then {
  2627.         message "selection overbraced"
  2628.     } else {
  2629.         message "enter text"
  2630. proc stackrel {} {
  2631.     checkMathMode "stackrel" 1
  2632.     set currentPos [getPos]
  2633.     if {[insertObject "\\stackrel{
  2634. "]} then {
  2635.         goto $currentPos
  2636.         nextTabStop
  2637.         message "1st arg scriptstyle"
  2638. #--------------------------------------------------------------------------
  2639. # Spacing:
  2640. #--------------------------------------------------------------------------
  2641. proc negThin {} {checkMathMode "negThin" 1; insertObject "\\!"}
  2642. proc thin {} {checkMathMode "thin" 1; insertObject "\\,"}
  2643. proc medium {} {checkMathMode "medium" 1; insertObject "\\:"}
  2644. proc thick {} {checkMathMode "thick" 1; insertObject "\\;"}
  2645. proc quad {} {checkMathMode "quad" 1; insertObject "\\quad"}
  2646. proc qquad {} {checkMathMode "qquad" 1; insertObject "\\qquad"}
  2647. proc hspace {} {
  2648.     checkMathMode "hspace" 1
  2649.     if {[wrapObject "\\hspace{" "}
  2650. "]} then {
  2651.         message "spacing set"
  2652.     } else {
  2653.         message "enter the desired horizontal spacing"
  2654. proc vspace {} {
  2655.     checkMathMode "vspace" 1
  2656.     if {[wrapObject "\\vspace{" "}
  2657. "]} then {
  2658.         message "spacing set"
  2659.     } else {
  2660.         message "enter the desired horizontal spacing"
  2661. proc hfill {} {checkMathMode "hfill" 1; insertObject "\\hfill"}
  2662. proc vfill {} {checkMathMode "vfill" 1; insertObject "\\vfill"}
  2663. proc smallskip {} {checkMathMode "smallskip" 1; insertObject "\\smallskip"}
  2664. proc medskip {} {checkMathMode "medskip" 1; insertObject "\\medskip"}
  2665. proc bigskip {} {checkMathMode "bigskip" 1; insertObject "\\bigskip"}
  2666.